Help translating excel equation to matlab

4 ビュー (過去 30 日間)
hydrogall
hydrogall 2016 年 2 月 4 日
コメント済み: Geoff Hayes 2016 年 2 月 4 日
I have the following equation in excel that I am trying to translate into matlab code...with much difficulty
=IF(M5>$AD$17,$AD$5+$AD$8,IF(N5>0,$AD$5+(O4-$AD$5)*EXP((IF(F5>273.16,$AD$11,$AD$14))*0.04167),0))
I don't know how to handle the last embedded IF statement...
This is what I have come up with, but I keep getting an error.
if T(t)>273.16;
Z(t)=DPp;
else
Z(t)=DPn;
end
if Ps(t)>SS; %Albedo
Albedo(t)=Amin+Aadd;
if SnowAge(t)>0;
Albedo(t)=Amin+(Albedo(t-1)-Amin)*exp(Z(t)*0.04167);
else
Albedo(t)= 0;
end
end
Thank you for any direction/help
  1 件のコメント
Geoff Hayes
Geoff Hayes 2016 年 2 月 4 日
Jessica - if I translate the Excel statement into something like pseudocode, wouldn't the above be
IF(M5>$AD$17)
x = $AD$5+$AD$8;
ELSE
IF(N5>0)
IF(F5>273.16)
y = $AD$11;
ELSE
y = $AD$14;
END
x = $AD$5+(O4-$AD$5)*EXP(y*0.04167);
ELSE
x = 0;
END
END
where x is the value of the cell that contains this Excel code (y is just a temporary value).

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

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by