So I have these formula's and information given to me. From question 1 I find the Zi values which I have done using Sym Z and solve, I found what B was no problem (I dont have what Go and Rs are in the pictures but it's in my script.) I am also given the first Pi values which is 101325, from that I put it into the equation and get what P(2) is. However my script is outputting me very different numbers to the answers of Pi in equation 5 and I cant figure out why.
Any help is appreciated!

 Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 9 de Sept. de 2020

0 votos

Hi,
In your code, there are a few errors with loop indexes. Here is the fixed part of the script that gives all correct answers:
...
Pa=Pi; HH=diff(hi); TT=Ti; AA=Ai_1; % New variables are introduced not to get confused with the variable names containing i :). This is optional though!
for i= 1:length(ai)
if AA(i) ==0
Pa(i+1)= real(Pa(i).*exp(-B*HH(i)/TT(i))); % Pressure values are saved
else Pa(i+1)=real(Pa(i)*(TT(i)/(TT(i)+ai(i)*HH(i))).^(B/AA(i))); % Pressure values are saved
end
end

7 comentarios

Liam Crocker
Liam Crocker el 9 de Sept. de 2020
Just a little confused as to why HH = diff (hi)
If you have Real in there, wouldn't that mean you are getting complex numbers which means im getting the wrong answer
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 9 de Sept. de 2020
diff(hi) is equivalent of hi(i+1)-hi(i)
Pa() values are all REAL not complex and real() not needed (was left unintentionally).
...
Pa=Pi; HH=diff(hi); TT=Ti; AA=Ai_1; % New variables are introduced not to get confused with the variable names containing i :). This is optional though!
for i= 1:length(ai)
if AA(i) ==0
Pa(i+1)= (Pa(i).*exp(-B*HH(i)/TT(i))); % Pressure values are saved
else Pa(i+1)=(Pa(i)*(TT(i)/(TT(i)+ai(i)*HH(i))).^(B/AA(i))); % Pressure values are saved
end
end
Liam Crocker
Liam Crocker el 9 de Sept. de 2020
Ah! Makes sense!
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 9 de Sept. de 2020
Would you accept the answer? Cheers :)
Liam Crocker
Liam Crocker el 9 de Sept. de 2020
Yes of course! My apologies!
Liam Crocker
Liam Crocker el 9 de Sept. de 2020
Hi Sulaymon,
When I call Pa(6), it returns me a very close value, but not the same as what's listen on the fprintf table below. Pa(6) for me returns 66.9464 where it is 66.9388 on the table, do you have any idea why?
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 9 de Sept. de 2020
Mostly, because of the value (gravitational acceleration):
go = 9.80666

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by