how to use if-else for select transition matrix input
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anuchit Wibun
am 3 Feb. 2015
Kommentiert: Michael Haderlein
am 4 Feb. 2015
d = 1,2,5,10 will use tm = p_clear but d = 3,4,7 will use tm = p_partly and d = 6,8,9 will use tm = p_cloudy. what command that i should use? The below is code that i wrote but it has problem about transition matrix that used not match with day. pleas help me.
if d == 1 || d == 2 || d == 3 | d == 4 || d == 5 || d == 7 || d == 17;
p = cdf_partly;
elseif d == 6 || d == 8 || d == 9 || d == 10;
p = cdf_mostly;
end
0 Kommentare
Akzeptierte Antwort
Julia
am 3 Feb. 2015
Hi,
I do not completely understand your problem, but you can write your conditions with a switch-case statement:
function p = test2(y)
switch y
case {1, 2, 5, 10};
p=0;
case {3, 4, 7};
p=1;
case {6, 8, 9};
p=2;
otherwise
p=-1;
end
end
6 Kommentare
Michael Haderlein
am 4 Feb. 2015
Ok, but what is the problem with Julia's answer? If you replace p=0 with p=cdf_clear and so on, it should work.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Visualization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!