For Loops

 
v = zeros(1,10);
for i=1:10
    v(i) = 2^i;
end

disp(v)
>>  2   4   8   16   32   64   128   256   512  1024
% break and continue
for i=1:10
    if i<=5
        disp(i);
    elseif i<8
        continue;
    else
        disp(sprintf('Exiting at: %d', i));
        break;
    end
end
>>
  1
  2
  3
  4
  5
  Exiting at: 8

Fibonacci numbers:

fn=fn1+fn2f_{n} = f_{n-1} + f_{n-2}

fib(1) = 1
fib(2) = 1

for n = 3:10
    fib(n) = fib(n-1) + fib(n-2);
end

fib
>>  1   1   2   3   5   8   13   21   34   55