plotting functions with different sizes

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 Kommentare

Cris LaPierre
Cris LaPierre am 3 Mai 2021
Bearbeitet: Cris LaPierre am 3 Mai 2021
Your code has an error preventing it from running.
Line 6 has this error:
Unrecognized function or variable 'ppu'.
Osama Aliwat
Osama Aliwat am 3 Mai 2021
Oh im sorry , i forgot to put in the value of ps , which is 0.95
Osama Aliwat
Osama Aliwat am 3 Mai 2021
Also i forgot the value of ppu , i edited it again.
1: sm is undefined
2: This is assigning a vector to a single element of another vector
p(i)=sqrt(r.^2-x.^2);
3: You say "how can i plot these functions" -- Other than p, which functions?
Osama Aliwat
Osama Aliwat am 3 Mai 2021
Thank you for your reply , sm=10 , by functions i mean the equations in if statement , the second and third i can plot them if i remove the first if statement , but the when i add the first if statement that in the equation has x and y , they have different lengths so its not possible to plot them togther , so i wanted to know if there is a way that i can do so
clc
clear
s=1; xs=1.5836; vp=1; k=0.63; em=2.5; ppu=0.8; ps=0.95; sm=10;
stepE=(vp):0.01:em*0.9;
radRNG=(stepE*vp)/xs;
r=radRNG-k;
y=(r-ppu*(sm/100));
x=(sqrt((r).^2-((y).^2)));
radRNG2=(0.9*em*vp)/xs;
r2=radRNG2-k;
y2=(r2-ppu*(sm/100));
x2=-(sqrt((r2).^2-((y2).^2)));
q=-s:0.001:s;
n=length(q);
for i=1:n
if q(i)>=x2 & 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(x-k,y+ppu*(sm/100),q,p)
ylim([0 s])
xlim([-s s])
xlabel('Q in p.u'); ylabel('P in p.u')
grid
After adjusting the code , this is the best i could get to where the could run , but as seen from the graph , im getting two different lines and couldnt manage to put it into single line.
KSSV
KSSV am 3 Mai 2021
You need to rethink on your code. What exactly you are trying to achieve?
Osama Aliwat
Osama Aliwat am 3 Mai 2021
I am trying to plot capability curve for a generator.
the curve should look like this
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Geographic Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 3 Mai 2021

Kommentiert:

DGM
am 3 Mai 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by