mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 15:23:11 +02:00
10 lines
401 B
Matlab
Executable File
10 lines
401 B
Matlab
Executable File
function b = vectorB(n) % We want n elements in the vector
|
|
b = zeros(n, 1); % in order to save speed we preallocate zeros to the vector
|
|
for i = 1 : n % We loop from first element to the last element of the vector
|
|
if mod(i, 2) == 0 % as per problem description
|
|
b(i, 1) = 9 / (2*i);
|
|
else
|
|
b(i, 1) = 0;
|
|
end % end if
|
|
end % end for
|
|
end % end function |