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])
채택된 답변
madhan ravi
2018년 12월 24일
hold on % after the first plot command
댓글 수: 12
Misbah Rashid
2018년 12월 24일
Can you give an example, please?
madhan ravi
2018년 12월 24일
편집: madhan ravi
2018년 12월 24일
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.
Misbah Rashid
2018년 12월 24일
It still shows one line for stall speed. How can I plot the other variables?

madhan ravi
2018년 12월 24일
편집: madhan ravi
2018년 12월 24일
Man provide all the datas to run your code , some parameters are not defined .
Misbah Rashid
2018년 12월 24일
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;
madhan ravi
2018년 12월 24일
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])
madhan ravi
2018년 12월 24일
편집: madhan ravi
2018년 12월 24일
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])

Misbah Rashid
2018년 12월 24일
It works now. Thank you so much!
madhan ravi
2018년 12월 24일
편집: madhan ravi
2018년 12월 24일
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.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
