Why does the for loop give wrong answer
Show older comments
Hello, I am trying to do a few operations with data in order to make some graphs for my report. During our lab we took some readings and now need to calculate the pressure coefficient for higher and lower surface with different angles of attack. Where did i make an error, since the matlab does not calculate it properly. This is formula I used. C_p = (local_pressure - ambient_pressure)/0.5*rho*V^2
In matlab I used this for command
the answer for 1st pressure should be about about -2.5 yet matlab gives the answer -3.0646e+05
Could someone tell mem where I made the mistake?
I attached my workspace above.
for i = 1:10
C_p_l_10(i) = (1000*lower_pressure(1,i)-ambient_pressure(1))/0.5*ambient_air_density*velocity(1)^2
end
2 Comments
Muhammad Usman
on 17 Nov 2019
As you mentioned in your formula, there is no multiplication with 1000, but if you want to scale down your result then you multiply 1E-05 and your code look like:
for i = 1:10
C_p_l_10(i) = 1e-05*(lower_pressure(1,i)-ambient_pressure(1))/0.5*ambient_air_density*velocity(1)^2;
end
C_p_l_10
simply display tour values outside loop
czakar
on 17 Nov 2019
Accepted Answer
More Answers (0)
Categories
Find more on Programming 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!

