How to perform mathematical conditions
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have to reproduce this plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/554712/image.jpeg)
The function is :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/554717/image.png)
As you see in the plot, on the Y-axis we have this condition : [0,-pi]
So my attempt:
function alfa= fas(O,Q)
a=O/Q; b=1-O.^2;
alfa = atan(-(a)./(b));
end
clc
clear all
O=0:0.01:3.1;
for Q = [2 5 10]
y=fas(O,Q);
plot(O,y)
hold on
grid on
xlabel('/Omega')
ylabel('phase')
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/554722/image.jpeg)
How can I get a plot just like the first one ?
I dont know how to perform the condition on Y-axis which is [0,-pi]
0 Kommentare
Antworten (1)
KSSV
am 18 Mär. 2021
Use atan2 instead of atan.
function alfa= fas(O,Q)
a=O/Q; b=1-O.^2;
alfa = atan2(-a, b);
end
6 Kommentare
Siehe auch
Kategorien
Mehr zu Line 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!