clc
clear
format long
R=287;
r=1.4;
Mach=[2:0.5:6];
for i=1:9
M=Mach(1,i);
for density=1.225
To=300;
p=101325;
ao=sqrt(r*R*To);
V=ao*M;
m=M^2;
P=p*(((2*r*m)-(r-1))/(r+1));
D=density*(((r+1)*m)/(((r-1)*m)+2));
Q=(D*((V^2)/2));
Po=P+Q;
plot(Po,P,'r*')
hold on
end
for density=1.203
To=284.9;
p=99507.54;
ao=sqrt(r*R*To);
V=ao*M;
m=M^2;
D=density*(((r+1)*m)/(((r-1)*m)+2));
Q=D*((V^2)/2);
P=p*(((2*r*m)-(r-1))/(r+1));
Po=P+Q;
plot(Po,P,'ko')
hold on
end
end
hold off
xlabel('Po')
ylabel('P')
legend('Wind Tunnel','FL500','Location','northwest')

1 件のコメント

Ankit Sahay
Ankit Sahay 2020 年 9 月 3 日
Please follow the community guidelines while asking questions. In short, explain what are you asking, why and what steps have you taken to solve your problem. Write your question in a way that a layman who has no idea of what you are trying to do can understand.

サインインしてコメントする。

 採用された回答

KSSV
KSSV 2020 年 9 月 3 日

0 投票

You can save the generated values into a vector/ matrix and plot at the end. Check the below code:
clc
clear
format long
R=287;
r=1.4;
Mach=[2:0.5:6];
x = zeros(9,2) ;
y = zeros(9,2) ;
for i=1:9
M=Mach(1,i);
for density=1.225
To=300;
p=101325;
ao=sqrt(r*R*To);
V=ao*M;
m=M^2;
P=p*(((2*r*m)-(r-1))/(r+1));
D=density*(((r+1)*m)/(((r-1)*m)+2));
Q=(D*((V^2)/2));
Po=P+Q;
plot(Po,P,'r*')
hold on
x(i,1) = Po ;
y(i,1) = P ;
end
for density=1.203
To=284.9;
p=99507.54;
ao=sqrt(r*R*To);
V=ao*M;
m=M^2;
D=density*(((r+1)*m)/(((r-1)*m)+2));
Q=D*((V^2)/2);
P=p*(((2*r*m)-(r-1))/(r+1));
Po=P+Q;
plot(Po,P,'ko')
hold on
x(i,2) = Po ;
y(i,2) = P ;
end
end
hold off
xlabel('Po')
ylabel('P')
figure
plot(x,y)

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2020 年 9 月 3 日

0 投票

You were overwriting P all the time, instead of storing all the values:
R=287;
r=1.4;
Mach=[2:0.5:6];
for i=1:9
M=Mach(1,i);
for density=1.225
To=300;
p=101325;
ao=sqrt(r*R*To);
V=ao*M;
m=M^2;
P(i)=p*(((2*r*m)-(r-1))/(r+1)); %%%%%%%%%%%%%%%%%%%%%%%%
D=density*(((r+1)*m)/(((r-1)*m)+2));
Q=(D*((V^2)/2));
Po(i)=P(i)+Q; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plot(Po,P,'r*')
hold on
end
for density=1.203
To=284.9;
p=99507.54;
ao=sqrt(r*R*To);
V=ao*M;
m=M^2;
D=density*(((r+1)*m)/(((r-1)*m)+2));
Q=D*((V^2)/2);
P2(i)=p*(((2*r*m)-(r-1))/(r+1)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%
Po2(i)=P2(i)+Q; %%%%%%%%%%%%%%%%%%%%%%%
plot(Po2,P2,'ko')
hold on
end
end
hold off
xlabel('Po')
ylabel('P')
legend('Wind Tunnel','FL500','Location','northwest')

1 件のコメント

KSSV
KSSV 2020 年 9 月 3 日
You have not intialized P1,P2,Po1,Po2.....
Every time they are being plotted in loop.

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2020 年 9 月 3 日

コメント済み:

2020 年 9 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by