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.
댓글 수: 0
채택된 답변
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!