필터 지우기
필터 지우기

Pressure calculation loop error

조회 수: 2 (최근 30일)
John Woods
John Woods 2020년 6월 26일
댓글: John Woods 2020년 6월 26일
I have to calculate the pressure at different altitudes. I have the code that calculate all of the variables to go into my pressure calculation and all of those run fine and seem to produce the values that I am looking for but when I try to run the pressure loop it says the sides have different values. Can anyone tell me where I am going wrong?
This is what I have so far:
clc;
clear all;
p(1)=1.013e5;
r=287; %Jules/kg*K
dz=200;
% =================== Gravity Calculations ============================
alt=0:200:50000;
Re=6.37e6;
g0=9.80665;
i=1:length(alt);
g=g0*((Re^2)./((alt(i)+Re).^2));
% =================== Temperature Calculations ============================
for i=1:length(alt)
if alt(i)<=11000
t(i)=((-71.5/11000).*alt(i)+15)+273;
elseif 11000<alt(i) && alt(i)<=20100
t(i)=(-56.5)+273;
elseif 20100<alt(i) && alt(i)<=32200
t(i)=((12/12100).*alt(i)-76.434)+273;
elseif 32200<alt(i) && alt(i)<=47300
t(i)=((42/15100).*alt(i)-134.063)+273;
else
t(i)=(-2.5)+273;
end
x=g./(r*t(i));
end
for i=1:length(alt)
p(i+1)=p(i).*((1/2)*x.*dz)+(1-(1/2)*x.*dz);
end
  댓글 수: 5
KSSV
KSSV 2020년 6월 26일
If you replace the loop with the given..I am not getting any error.....your error is becuse you are using x, replace ot with x(i).
John Woods
John Woods 2020년 6월 26일
Oh okay I just changed the for line. I got it now. Thank you so much!

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by