plotting functions with different sizes

7 views (last 30 days)
Osama Aliwat
Osama Aliwat on 3 May 2021
Commented: DGM on 3 May 2021
s=1; xs=1.5836; vp=1; k=0.63; em=2.5; ppu=0.8; ps=0.95; sm=10;
q=-s:0.001:s;
stepE=vp:0.001:0.9*em;
radRNG=(stepE*vp)/xs;
r=radRNG-k;
y=(r-ppu*(sm/100));
if y<0
y=-y;
end
x=-(sqrt((r).^2-((y).^2)));
n=length(q);
for i=1:n
if q(i)>=-k & q(i)<=(0.9*em*vp)./xs
p(i)=sqrt(r.^2-x.^2);
elseif q(i)>=(0.9*em*vp)./xs & q(i)<=ps
p(i)=sqrt(s.^2-q(i).^2);
elseif q(i)>ps & q(i)<=s
p(i)=0;
end
end
p(p>ppu)=ppu;
figure(1)
plot(q,p)
ylim([0 s])
xlim([-s s])
xlabel('Q in p.u'); ylabel('P in p.u')
How can I plot these functions assuming i have different sizes ? I have x and y as points in first if statement with different size than q and i want to plot
  9 Comments
Osama Aliwat
Osama Aliwat on 3 May 2021
I am trying to plot capability curve for a generator.
the curve should look like this
DGM
DGM on 3 May 2021
It almost looks like you're trying to plot a piecewise 1D function of q, but your intervals all overlap, so I have no idea what you're actually trying to plot.
% your plotting intervals in terms of q:
% interval 1 is [-k (0.9*em*vp)/xs]
% interval 2 is (-inf ps] & [(0.9*em*vp)/xs inf)
% interval 3 is (ps s]
% so the intervals stack up like
% [-0.63 -------------- 1.42]
% (-inf --------- 0.95] [1.42 -------------- inf)
% [0.95 -- 1.00]
% but q is only defined over [-1 1]
Furthermore, the function that would be plotted in interval 1 isn't even a function of q, so the idea that this is a piecewise function of q doesn't make much sense to me. In fact, this whole thing:
if y<0
y=-y;
end
x=-(sqrt((r).^2-((y).^2)));
% ...
p=sqrt(r.^2-x.^2);
Is a convoluted way of saying:
p = abs(y);
I don't even see that x or y are used for anything else.
You're going to have to figure out what you're trying to plot and how you want it plotted. I can't tell.

Sign in to comment.

Answers (0)

Categories

Find more on 2-D and 3-D 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!