# MATLAB: Set order of elseif

if statement

Updated.
I have this code structure inside a loop. x, y and z are 1/0 variables. In this case the order of the elseif statement is: first x is evaluated, then y then z
if x      %code for case x    elseif y    %code for case yelseif z     %code for case z    end
I would like to define a varible order (for the previous case order={'caseX','caseY','caseZ'}), where I can change the order in which the elseif statement is evaluated. So if I set order={'caseZ','caseX','caseY'}, I should get this: (first z is evaluated, then x then y)
order={'caseZ','caseX','caseY'}%%% then if z      %code for case z    elseif x    %code for case xelseif y     %code for case y    end
An hint will be appreciated.

order = [1 2 3]; % or whateverfor k=1:numel(order)    switch order(k)    case 1        if( x )            % code for case x            break;        end    case 2        if( y )            % code for case y            break;        end    case 3        if( z )            % code for case z            break;        endend