How to perform mathematical conditions

1 次查看(过去 30 天)
I have to reproduce this plot:
The function is :
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
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]

回答(1 个)

KSSV
KSSV 2021-3-18
Use atan2 instead of atan.
function alfa= fas(O,Q)
a=O/Q; b=1-O.^2;
alfa = atan2(-a, b);
end
  6 个评论
Rik
Rik 2021-3-18
Where do you see an 'if condition'? And why do you want to avoid atan2?
Pouyan Msgn
Pouyan Msgn 2021-3-18
It was little hard for me to understand the logic of atan2... but thank you anyway

请先登录,再进行评论。

类别

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