WUT_Computer_Science/NotProgramming/ENUME/projectA/vectorB.m

10 lines
401 B
Mathematica
Raw Permalink Normal View History

2021-11-06 00:26:00 +01:00
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