필터 지우기
필터 지우기

vector length different interval problem

조회 수: 2 (최근 30일)
Austen Thomas
Austen Thomas 2018년 2월 16일
답변: Niwin Anto 2018년 2월 21일
I am having trouble making two equations vary over different intervals. I need v to go up to 950 i know why its not working i just dont know how to fix it. M on the x axis should go up to about 0.9.
What i am wondering is how would i make a for loop for both the height h and the velocity with when both are changing?
clc,clear
T0=46500; a=994.71; T_SSL=518.69; rho_SSL=0.002377; m=0.6; g=32.2; R=1716; aL=-0.003563; x = g./(a.*R); h0=0.0;
Z=h0:5000:45000; W=50:10:950; for i = 1:numel(Z) h(i) = Z(i); v(i) = W(i);
T(i) = T_SSL+aL*h(i);
rho(i) = rho_SSL*((T(i)/T_SSL)^-(x+1));
TH2(i)=T0*(rho(i)/rho_SSL)^m;
M(i) = v(i)/a;
end
plot(M,TH2);
xlabel('Mach Number'); ylabel('Thrust Available (lb)'); title('Thrust Available vs Mach Number');

답변 (1개)

Niwin Anto
Niwin Anto 2018년 2월 21일
The question is not clear. What I understood is, you want the same number of elements in different interval range.
You can use 'linspace(x1,x2,n)' function for generate linearly spaced vector.
clc,clear
T0=46500;
a=994.71;
T_SSL=518.69;
rho_SSL=0.002377;
m=0.6;
g=32.2;
R=1716;
aL=-0.003563;
x = g./(a.*R);
h0=0.0;
%Z=h0:5000:45000; W=50:10:950;
Z = linspace(h0,45000,50);
W = linspace(50,950,50);
for i = 1:numel(Z)
h(i) = Z(i);
v(i) = W(i);
T(i) = T_SSL+aL*h(i);
rho(i) = rho_SSL*((T(i)/T_SSL)^-(x+1));
TH2(i)=T0*(rho(i)/rho_SSL)^m;
M(i) = v(i)/a;
end
plot(M,TH2);
xlabel('Mach Number');
ylabel('Thrust Available (lb)');
title('Thrust Available vs Mach Number');

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by