%'for' LOOP EXAMPLES:
%(Selcuk Bayin, METU-NCC, bayin@metu.edu.tr)
%EXAMPLE 1
clc
clear y
y=zeros(1,7);
for m=0:6
    y(m+1)=sin(pi*m/6);
end
y
%%
y'
%%
%EXAMPLE 2
clc
clear x
for n=0:3:6
    x(n+1)=sin(pi*n/6);
end
x
%%
clc
x=zeros(1,4)
for n=1:2:7
    x(n)=sin(pi*(n-1)/6);
end
%%
x
%%
x([1,3,5,7])
%%
%EXAMPLE 3
clc
H=zeros(5);
for m=1:5
    for n=1:5
    H(m,n)=1/(m+1-1);
    end
end
H
%%
%EXAMPLE 4
clc
A=zeros(6);
for k=1:6
    for n=1:6
        A(k,n)=sin(k)*cos(n);
    end
end
A
%EXAMPLE 5
%Another way:Without a loop
clc
k=1:6;
A=sin(k)'*cos(k);
A
%%
%IN DETAIL
C=sin(k)
%%
C'
%%
D=cos(k)
%%
C'*D
%%
