Check out example codes for "matlab if statement". It will help you in understanding the concepts better.

Code Example 1

for c = 1:ncols     for r = 1:nrows                  if r == c             A(r,c) = 2;         elseif abs(r-c) == 1             A(r,c) = -1;         else             A(r,c) = 0;         end              end end A

Code Example 2

if r == c   A(r,c) = 2; elseif abs(r-c) ~= 1   A(r,c) = -1; else   A(r,c) = 0; end

Code Example 3

if expression     statements elseif expression     statements else     statements end

Learn ReactJs, React Native from akashmittal.com