Attempting to Plot atand function and nothing appears in plot, any suggestions?

1 次查看(过去 30 天)
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.

采纳的回答

dpb
dpb 2017-4-16
>> 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... :)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by