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
Image Analyst
2018 年 12 月 24 日
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.
Misbah Rashid
2018 年 12 月 24 日
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..
Misbah Rashid
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')
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
