WUT_Computer_Science/ENUME/references/ENUME_ProjectA_No31/task 3/matrixGen2a.m
2021-11-10 13:12:25 +01:00

22 lines
395 B
Matlab

function [A, b] = matrixGen2a(n)
%matrixGen2a Generates matrices for the task 2a
% generates matrices for a system Ax = B of n linear equations
A = zeros(n, n);
b = zeros(n, 1);
for i = 1:n
b(i) = 0.9*i;
for j = 1:n
if(i == j)
A(i, j) = 11;
elseif (i == j-1)
A(i, j) = 5;
elseif (i == j+1)
A(i, j) = 5;
end
end
end
end