MATLAB: How to return any iteration in for loop results

for loop

x=[1 2 3 4]
y=[5 6 7 8]
n=lenght(x)
if i=1:n
z=x(i).*y
end
the result will be four different vector with four elements each, but z will only return the last one,
Hoe I can give definition to all iteration results and use them in different calculations.

Best Answer

x=[1 2 3 4]
y=[5 6 7 8]
n=length(x)
for i=1:n
z(i,:)=x(i).*y
end
Related Question