Attempting to Plot atand function and nothing appears in plot, any suggestions?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Grant Griffin
am 16 Apr. 2017
Kommentiert: Grant Griffin
am 16 Apr. 2017
w0 = 1;
w = [0:1:50];
q0 = 1;
y = 20*log10(sqrt((1-(w/w0).^2).^2+(w/(w0*q0)).^2));
x = atand(((w/(w0*q0)))/(1-(w/w0).^2));
plot(w,y)
grid on;
figure()
plot(w,x)
I am trying to plot second order frequency response for a particular form. I've tried using the bode and plot function to plot the phase and magnitude of a specific function for varying values of Q.
Nothing appears for the plot(w,x) I am expecting a 0 - 180 degree phase shift once w reaches 100.
Where am I going wrong? The first plot(w,y) functions as expected.
0 Kommentare
Akzeptierte Antwort
dpb
am 16 Apr. 2017
>> whos w
Name Size Bytes Class Attributes
w 1x51 408 double
>> whos x
Name Size Bytes Class Attributes
x 1x1 8 double
>>
OK, why dat???
x = atand(((w/(w0*q0)))/(1-(w/w0).^2));
Aha! "/" is matrix divide or mrdivide internally.
>> help mrdivide
/ Slash or right matrix divide.
A/B is the matrix division of B into A, which is roughly the
same as A*INV(B) , except it is computed in a different way.
...
What you're looking for here is element-wise division; these are the "dot" operators in Matlab--
Use
>> x = atand(((w/(w0*q0)))./(1-(w/w0).^2)); % instead, note the "./"
>> whos x
Name Size Bytes Class Attributes
x 1x51 408 double
>>
Now you'll see what you're expecting...
BTW, everybody has got to learn this sooner of later... :)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!