How to perform mathematical conditions
Show older comments
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]
Answers (1)
KSSV
on 18 Mar 2021
Use atan2 instead of atan.
function alfa= fas(O,Q)
a=O/Q; b=1-O.^2;
alfa = atan2(-a, b);
end
6 Comments
Pouyan Msgn
on 18 Mar 2021
KSSV
on 18 Mar 2021
Normalize y.
Rik
on 18 Mar 2021
The plot you posted in your question is a bit confusing. Are the y-axis units pi in that plot? In that case you can simply divide the phase by pi to rescale your y-axis.
Pouyan Msgn
on 18 Mar 2021
Rik
on 18 Mar 2021
Where do you see an 'if condition'? And why do you want to avoid atan2?
Pouyan Msgn
on 18 Mar 2021
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!