Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bode plot discrepancy

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?

like image 250
suzu Avatar asked Apr 22 '26 02:04

suzu


1 Answers

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;
like image 120
klurie Avatar answered Apr 24 '26 23:04

klurie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!