How can I plot multiple lines on the graph?

Hello! I'm trying to graph a matching plot for aircraft sizing. However, only one plot is showing. How can I display all the other lines? My code is below:
Vs = 141;
Vc = 822;
Vmax = 1210;
Vto = 150;
Vr = Vto;
hc = 41000;
hac = 51000;
Clmax = 1.8;
e = 0.81;
AR = 8;
K = 0.049;
g = 32.2;
Cd0 = 0.017;
Cd0to = 0.032;
Clto = 1;
Cdto = 0.037;
Cdg = 0.001;
Clr = 1.48;
nu = 0.04;
Sto = 4000;
rhosl = 0.002378;
rhoc = 0.00056;
rhoac = 0.000347;
mupac = 0.235;
LDmax = 15;
ROCAC = 0;
ROCSC = 100;
ROCCrC = 3500;
ROCCoC = 500;
% Stall speed.
WS = 1/2*rhosl*Vs^2*Clmax;
x1 = WS;
x2 = WS;
y1 = 0;
y2 = 1.5;
plot([x1,x2],[y1,y2],'-g')
text(55,1.2,'Stall speed')
xlabel('W/S, lb/ft^2')
ylabel('T/W, lb/lb')
grid on
hold on
% Maximum speed.
WSms = 0:2:80;
TWvmax = (59./2*(W/S))+((0.00051)*(WS));
plot(WSms,TWvmax,'--r')
text(10,-0.05,'Maximum speed')
% Take-off run.
TWsto = (nu-(nu+Cdg/Clr).*(exp(0.6*rhosl*g*Cdg*Sto)./WSms))./((1-exp(0.6*rhosl*g*Cdg*Sto)./WSms));
plot(WSms, TWsto,'b--o')
text(5,1.2,'Take-off run')
% Rate of climb.
TWroc = (3500./(sqrt(451.*WSms)))+(1./15);
plot(WSms, TWroc,'*-c')
text(5,0.3,'Rate of climb')
% Cruise ceiling.
TWhc = (100./(0.19*sqrt(2324*WSms)))+(1./2.85);
plot(WSms, TWhc,'*-y')
text(10,0.5,'Cruise ceiling')
% Find design plot coordinates.
[xint,yint] = polyxpoly([x1,x2],[y1,y2],WSms,TWvmax);
plot(xint,yint,'ok')
text(65,-0.2,'Design point')
disp([xint,yint])

 Accepted Answer

hold on % after the first plot command

12 Comments

Can you give an example, please?
Vs = 141;
Vc = 822;
Vmax = 1210;
Vto = 150;
Vr = Vto;
hc = 41000;
hac = 51000;
Clmax = 1.8;
e = 0.81;
AR = 8;
K = 0.049;
g = 32.2;
Cd0 = 0.017;
Cd0to = 0.032;
Clto = 1;
Cdto = 0.037;
Cdg = 0.001;
Clr = 1.48;
nu = 0.04;
Sto = 4000;
rhosl = 0.002378;
rhoc = 0.00056;
rhoac = 0.000347;
mupac = 0.235;
LDmax = 15;
ROCAC = 0;
ROCSC = 100;
ROCCrC = 3500;
ROCCoC = 500;
% Stall speed.
WS = 1/2*rhosl*Vs^2*Clmax;
x1 = WS;
x2 = WS;
y1 = 0;
y2 = 1.5;
plot([x1,x2],[y1,y2],'-g')
text(55,1.2,'Stall speed')
xlabel('W/S, lb/ft^2')
ylabel('T/W, lb/lb')
grid on
hold on
% Maximum speed.
WSms = 0:2:80;
TWvmax = (59./2*(W/S))+((0.00051)*(WS));
plot(WSms,TWvmax,'--r')
hold on %-------------------------------------> just this line was sufficient
text(10,-0.05,'Maximum speed')
% Take-off run.
TWsto = (nu-(nu+Cdg/Clr).*(exp(0.6*rhosl*g*Cdg*Sto)./WSms))./((1-exp(0.6*rhosl*g*Cdg*Sto)./WSms));
plot(WSms, TWsto,'b--o')
text(5,1.2,'Take-off run')
% Rate of climb.
TWroc = (3500./(sqrt(451.*WSms)))+(1./15);
plot(WSms, TWroc,'*-c')
text(5,0.3,'Rate of climb')
% Cruise ceiling.
TWhc = (100./(0.19*sqrt(2324*WSms)))+(1./2.85);
plot(WSms, TWhc,'*-y')
text(10,0.5,'Cruise ceiling')
% Find design plot coordinates.
[xint,yint] = polyxpoly([x1,x2],[y1,y2],WSms,TWvmax);
plot(xint,yint,'ok')
text(65,-0.2,'Design point')
disp([xint,yint])
Note : Some parameters are not defined in the code that you provided.
It still shows one line for stall speed. How can I plot the other variables?
madhan ravi
madhan ravi on 24 Dec 2018
Edited: madhan ravi on 24 Dec 2018
Man provide all the datas to run your code , some parameters are not defined .
I did whatever you said, but it still didn't work
In
TWvmax = (59./2*(W/S))+((0.00051)*(WS));
what is W? Please provide W and any other parameters so we can just copy your code and run it.
My bad. It's supposed to be WS, not W/S.
These are my parameters:
Vs = 141;
Vc = 822;
Vmax = 1210;
Vto = 150;
Vr = Vto;
hc = 41000;
hac = 51000;
Clmax = 1.8;
e = 0.81;
AR = 8;
K = 0.049;
g = 32.2;
Cd0 = 0.017;
Cd0to = 0.032;
Clto = 1;
Cdto = 0.037;
Cdg = 0.001;
Clr = Clto;
nu = 0.04;
Sto = 4000;
rhosl = 0.002378;
rhoc = 0.00056;
rhoac = 0.000347;
mupac = 0.235;
LDmax = 15;
ROCAC = 0;
ROCSC = 100;
ROCCrC = 3500;
ROCCoC = 500;
upload the full code that your trying because I can't run your code without error..
Vs = 141;
Vc = 822;
Vmax = 1210;
Vto = 150;
Vr = Vto;
hc = 41000;
hac = 51000;
Clmax = 1.8;
e = 0.81;
AR = 8;
K = 0.049;
g = 32.2;
Cd0 = 0.017;
Cd0to = 0.032;
Clto = 1;
Cdto = 0.037;
Cdg = 0.001;
Clr = Clto;
nu = 0.04;
Sto = 4000;
rhosl = 0.002378;
rhoc = 0.00056;
rhoac = 0.000347;
mupac = 0.235;
LDmax = 15;
ROCAC = 0;
ROCSC = 100;
ROCCrC = 3500;
ROCCoC = 500;
% Stall speed.
WS = 1/2*rhosl*Vs^2*Clmax;
x1 = WS;
x2 = WS;
y1 = 0;
y2 = 8;
plot([x1,x2],[y1,y2],'-g')
text(55,1.2,'Stall speed')
axis([0 80 -2 10])
xlabel('W/S, lb/ft^2')
ylabel('T/W, lb/lb')
grid on
hold on
% Maximum speed.
WS = 0:2:80;
TWvmax = (59./2*(WS))+((0.00051)*(WS));
plot(WS,TWvmax,'--r')
text(10,-0.05,'Maximum speed')
% Take-off run.
TWsto = (nu-(nu+Cdg/Clr).*(exp(0.6*rhosl*g*Cdg*Sto)./WS))./((1-exp(0.6*rhosl*g*Cdg*Sto)./WS));
plot(WS, TWsto,'b--o')
text(5,1.2,'Take-off run')
% Rate of climb.
TWroc = (3500./(sqrt(451.*WS)))+(1./15);
plot(WS, TWroc,'*-c')
text(5,0.3,'Rate of climb')
% Cruise ceiling.
TWhc = (100./(0.19*sqrt(2324*WS)))+(1./2.85);
plot(WS, TWhc,'*-y')
text(10,0.5,'Cruise ceiling')
% Find design plot coordinates.
[xint,yint] = polyxpoly([x1,x2],[y1,y2],WS,TWvmax);
plot(xint,yint,'ok')
text(65,-0.2,'Design point')
disp([xint,yint])
Vs = 141;
Vc = 822;
Vmax = 1210;
Vto = 150;
Vr = Vto;
hc = 41000;
hac = 51000;
Clmax = 1.8;
e = 0.81;
AR = 8;
K = 0.049;
g = 32.2;
Cd0 = 0.017;
Cd0to = 0.032;
Clto = 1;
Cdto = 0.037;
Cdg = 0.001;
Clr = Clto;
nu = 0.04;
Sto = 4000;
rhosl = 0.002378;
rhoc = 0.00056;
rhoac = 0.000347;
mupac = 0.235;
LDmax = 15;
ROCAC = 0;
ROCSC = 100;
ROCCrC = 3500;
ROCCoC = 500;
% Stall speed.
WS = 1/2*rhosl*Vs^2*Clmax;
x1 = WS;
x2 = WS;
y1 = 0;
y2 = 8;
plot([x1,x2],[y1,y2],'-g')
text(55,1.2,'Stall speed')
axis([0 80 -2 10])
xlabel('W/S, lb/ft^2')
ylabel('T/W, lb/lb')
grid on
hold on
% Maximum speed.
WS = 0:2:80;
TWvmax = (59./2*(WS))+((0.00051)*(WS));
plot(WS,TWvmax,'--r')
hold on
text(10,-0.05,'Maximum speed')
% Take-off run.
TWsto = (nu-(nu+Cdg/Clr).*(exp(0.6*rhosl*g*Cdg*Sto)./WS))./((1-exp(0.6*rhosl*g*Cdg*Sto)./WS));
plot(WS, TWsto,'b--o')
text(5,1.2,'Take-off run')
% Rate of climb.
TWroc = (3500./(sqrt(451.*WS)))+(1./15);
plot(WS, TWroc,'*-c')
text(5,0.3,'Rate of climb')
% Cruise ceiling.
TWhc = (100./(0.19*sqrt(2324*WS)))+(1./2.85);
plot(WS, TWhc,'*-y')
text(10,0.5,'Cruise ceiling')
% Find design plot coordinates.
[xint,yint] = polyxpoly([x1,x2],[y1,y2],WS,TWvmax);
plot(xint,yint,'ok')
text(65,-0.2,'Design point')
disp([xint,yint])
Screen Shot 2018-12-24 at 9.37.35 PM.png
It works now. Thank you so much!
madhan ravi
madhan ravi on 24 Dec 2018
Edited: madhan ravi on 24 Dec 2018
Anytime :) , make sure to accept the answer if it worked.
After all it was just to add hold on after the first plot command as I suggested at the very beginning.

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks 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!