% Unit 2 (MATLAB Course @ UAM)
% (c) Alexander Knebe

%=============================================
% matrix generation
%=============================================
clear all
close all
clc

L = 15;

% matrix M
%--------------
M = zeros(L,L);
for i=1:L
    for j=1:L
        if i>= j
            n = i-1;
            m = j-1;
            M(i,j) = factorial(n)/(factorial(m).*factorial(n-m));
        end
    end
end
M

% matrix N
%--------------
N = zeros(L,L);
for i=1:L
    for j=1:L
        if(mod(M(j,i),2) == 0)
            N(i,j) =  M(j,i);
        else
            N(i,j) = -M(j,i);
        end
    end
end
N

% visualize matrix M or N
%------------------------------
figure(11)
surf(M)
xlabel('j')
ylabel('i')
zlabel('M')
figure(12)
surf(N)
xlabel('j')
ylabel('i')
zlabel('N')

