if i == 1, how to implement in matlab in matlab

To implement an "if" statement in MATLAB, you can use the following syntax:

main.m
if i == 1
    % code to be executed if i is equal to 1
else
    % code to be executed if i is not equal to 1
end
113 chars
6 lines

Here's an example:

main.m
i = 1;

if i == 1
    disp('i is equal to 1');
else
    disp('i is not equal to 1');
end
89 chars
8 lines

In the above code, if the value of i is equal to 1, it will display "i is equal to 1". Otherwise, it will display "i is not equal to 1".

gistlibby LogSnag