Help translating excel equation to matlab

2 views (last 30 days)
hydrogall
hydrogall on 4 Feb 2016
Commented: Geoff Hayes on 4 Feb 2016
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 Comment
Geoff Hayes
Geoff Hayes on 4 Feb 2016
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).

Sign in to comment.

Answers (0)

Categories

Find more on Data Import from MATLAB 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!