필터 지우기
필터 지우기

what to do when array indicies exceed for , FOR loop comparision for below , trying to plot density of atmosphere, how to do the comparison ?

조회 수: 1 (최근 30일)
h(1) = 0;
T(1) = 273.15;
p(1) = 101.2;
for t = 1:328084
if h(t)<[11000]
T(t+1) = 15.04 - 0.00649.*h(t);
p(t+1) = 101.29 .*((T(t) + 273.15) /288.08).^5.256;
elseif [11000]> h(t) && h(t)<=[25000]
T(t) = -56.46;
p(t+1) = 22.65.*e^(1.73-0.000157.*h(t));
elseif h(t)>[25000]
T(t) = -131.21+0.00299.*h(t);
p(t+1) = 2.488 .* ((T(t) + 273.15)/216.6).^-11.388;
end
rho_h(t) = p(t) ./(0.2869 * (T(t) + 273.15))
end
figure(1)
plot(T,h)
grid on
legend on
figure(2)
plot(rho_h, h)
grid on
legend on

채택된 답변

Walter Roberson
Walter Roberson 2021년 9월 24일
h(1) = 0;
That is the only place you assign to h
if h(t)<[11000]
but you need h to be 328084 elements by the end of the loop.
  댓글 수: 8
SL
SL 2021년 9월 25일
편집: SL 2021년 9월 25일
perfect thank you very much highly appreciate it

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by