Trying to do calculations for density

13 ビュー (過去 30 日間)
Sean St Cyr
Sean St Cyr 2020 年 7 月 1 日
コメント済み: Sean St Cyr 2020 年 7 月 1 日
%% Variables
% Input
% P_t - Total pressure [atm]
% P_s - Surface pressure [atm]
% H - Height [ft]
% Output
% rho - Density [kg/m^3]
% Other
% g - Gravity [m/s^2]
% Write your entire function code below here (Including header)
function [Rho] = RQ16_18(P_t,P_s,H) % The order of input variables should be Total Pressure, Surface Pressure, and Height
% Constants
P_t=4;
P_s=3;
H=25;
% Calculations
H = H/3.281; %Convert Ft to Meters
Tp = P_t * 101325; %Convert Atm to Pascals
Sp = P_s * 101325; %Convert Atm to Pascals
g = 9.8; %gravity
Rho = (Tp - Sp)/(g*H); %Density
end
I am trying to get the density and its defined as Rho however when matlab grader grades it it says the value is wrong. Am I missing a conversion? or Caluclation?

採用された回答

James Tursa
James Tursa 2020 年 7 月 1 日
Why do you have these lines in your function:
P_t=4;
P_s=3;
H=25;
Aren't these variable supposed to be input arguments? Seems like you should delete these lines since they overwrite the input arguments.
  1 件のコメント
Sean St Cyr
Sean St Cyr 2020 年 7 月 1 日
Oh my gosh, Thank you, I was completely overlooking those, just needed a another set of eyes

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by