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