mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 16:23:11 +02:00
22 lines
395 B
Matlab
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
|
|
|