to plot Magnitude of a system versus angular frequency

sir\mam, i want to plot Magnitude of a system (in 's') versus omega(angular frequency) for my study analysis; so please guide me for the same; for eg: plotting sys= 1/(s + 2) ; now plotting its Magnitude versus angular frequency

 Accepted Answer

The easiest way:
s = tf('s');
sys= 1/(s + 2);
figure(1)
bode(sys)
See the documentation on the bode (link) function for details. (If you want to change the plot properties, you cannot in the plot bode produces. You have to get the magnitude, phase, and frequency as outputs from bode. You can then use subplot to plot them as you want them.)

6 Comments

Hi Star Strider, i want to plot Magnitude (in Linear sweep); Bode plot will give Magnitude (in DB); so hope you understand my query
I have no idea what you intend by ‘linear sweep’.
The bode plot calculates the absolute magnitude (and phase) at the frequencies that you provide to it (or that it calculates itself, if you do not provide your own frequency vector). It provides the plot in dB. You can get the absolute magnitude and phase and frequencies if you ask for the first 3 outputs from the bode function.
Please see the description of everything the function can do, and that you can get from it, in the link to the documentation I provided in my original Answer.
Hi Star Strider, i have attached an image file explaining about my query; In the image file sys=1/(s + 2); hope now you understand me
Try this:
s = tf('s');
sys= 1/(s + 2);
w = linspace(0, pi, 250); % Specify Radian Frequency Vector
[mag,phase,wout] = bode(sys,w);
figure(1)
subplot(2,1,1)
plot(wout, squeeze(mag))
ylabel('Magnitude')
axis tight
grid
subplot(2,1,2)
plot(wout, squeeze(phase))
ylabel('Phase °')
xlabel('Frequency (rad/sec)')
axis tight
grid
The bode function will give you exactly what you want. See the documentation on it, and the other functions I use here, for details on what they are, what they do, and how best to use them.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!