Hamza Mezo
Hamza Mezo

Reputation: 47

Lines are not appeared in the graph

I am trying to plot the following function in MATLAB, but The lines are not shown up. Can anyone help me with it please. Thank you.

x=1;
PiD=10;
PiC=20;
PiP=50;
Vhigh=4;
Vlow=0;
Vmax=5;
Vmin=-1;
A1=2;
A0=-4;
Dt=[(Vmax/A1)-(Vmax/A0)]+[((Vlow-Vmin)+(Vmax-Vhigh))/A1]+[((Vmax-Vhigh)+(Vlow-Vmin))/A0];
for i=-x:0.1:x
DPiI=PiD+[PiC*(Vhigh/A1)]+PiP*i+PiC*i;
PiE=DPiI/Dt;
end
plot (x,PiE)

Upvotes: 0

Views: 69

Answers (2)

Kushal
Kushal

Reputation: 144

The PiE variable is a scalar. Try making it a vector as follows:
...
PiE = []
j = 1;
Dt=[(Vmax/A1)-(Vmax/A0)]+[((Vlow-Vmin)+(Vmax-Vhigh))/A1]+[((Vmax-Vhigh)+(Vlow- 
Vmin))/A0];
for i=-x:0.1:x
DPiI=PiD+[PiC*(Vhigh/A1)]+PiP*i+PiC*i;
PiE(j)=DPiI/Dt;
j=j+1;
end
plot (x,PiE)

Upvotes: 0

Tom
Tom

Reputation: 445

I made some additions to lhopital's answer and it seems to pass initial testing.

...
for i=-x:0.1:x
   DPiI=PiD+[PiC*(Vhigh/A1)]+PiP*i+PiC*i;
   PiE(j)=DPiI/Dt;
   i2(j) = i;
   j=j+1;
end
plot (i2,PiE,'bo-')

Upvotes: 1

Related Questions