# Surf respresentation of a transfer function depending on the frequency and the gain of the feedback

1 view (last 30 days)
salma el asmai on 12 Sep 2016
Answered: Teja Muppirala on 13 Sep 2016
Hi,
Please I would like to know if it is possible to plot a transfer function that depends on the variable "s" but also the gain of the feedback.
I give you below the part of my program that is related to my question. (A,B,C,D and alpha are defined already).
sys=ss(A,B,C,D);
gain=1;
H=tf(gain*[1 2*alpha alpha^2],[1 0]);
BF=feedback(sys,H,2,2);
bode BF(1,1);
This program is perfectly working and I can plot the bode diagram of BF(1,1) for example directly.
What I want to do though, is to plot BF(1,1) for different values of the variable gain, let's say for gain varying from 1 to 100, and to have then a 3D representation of BF(1,1) according to the parameter "s" (the frequency) and the parameter gain in the feedback function.
I hope that my question is clear and I hope I find an answer for it.
Thank you,

Teja Muppirala on 13 Sep 2016
You can loop over different values of "gain" and collect the results in a matrix and then plot it as a surface.
rng(0)
alpha = 1;
gainList = 1:100;
w = logspace(-1,3,51);
magSurf = [];
for n = 1:numel(gainList)
gain = gainList(n);
H=tf(gain*[1 2*alpha alpha^2],[1 0]);
BF=feedback(sys,H,2,2);
[mag,phase] = bode(BF(1,1),w);
magSurf(n,:) = mag(:);
end
surf(w,gainList,20*log10(magSurf));
set(gca,'Xscale','log')
ylabel('gain')
zlabel('Magnitude BF(1,1) dB')