vector length different interval problem

3 views (last 30 days)
Austen Thomas
Austen Thomas on 16 Feb 2018
Answered: Niwin Anto on 21 Feb 2018
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');

Answers (1)

Niwin Anto
Niwin Anto on 21 Feb 2018
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');

Categories

Find more on App Building in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!