% Example of if-then-elseif-else
% Minas Spetsakis, Oct. 2018

x=rand
if x<=.2
    res = 1;
elseif x<=.5000
    res = 2;
elseif x<=.7
    res = 3;
else
    res = 4;
end;
fprintf('res = %2i\n',res);

switch res
    case 1
        fprintf('res is one\n')
    case 2
        fprintf('res is two\n')
    case 3
        fprintf('res is three\n')
    case 4
        fprintf('res is four\n')
    otherwise
        fprintf('res is whatever\n')
end
