I am plotting the following
Cu4 = tf([1 2], [1 2 6]);
[magCu4 phaseCu4 wout] = bode(Cu4,logspace(-2,7,300));
magCu4 = squeeze(magCu4);
phaseCu4 = squeeze(phaseCu4);
semilogx(wout,20*log10(magCu4)),grid;
hold on
bode(Cu4,'r')
I would expect that the semilogx plot would return an identical plot as 'bode'. however, this doesn't seem to be the case. Does anyone know what is going wrong here?
The difference is that you do not specify a frequency vector in your second call to bode so MATLAB chooses a default vector (in your code it had length of 46).
Instead you could try:
bode(Cu4,'r',logspace(-2,7,300))
Compare the plots made by the following code
[magCu4 phaseCu4 wout] = bode(Cu4,logspace(-2,7,300));
magCu4 = squeeze(magCu4);
figure(1);
semilogx(wout,20*log10(magCu4))
hold on;
bode(Cu4,'r')
hold off;
figure(2);
semilogx(wout,20*log10(magCu4))
hold on;
bode(Cu4,'r',logspace(-2,7,300))
hold off;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With