I'm trying to write some code in matlab that will manipulate each element in a vector and will also return a vector. So basically if I have a vector x = [1 2 3 4 5]'; I would like to perform 2 * x(i) * i, where i is the ith element in the vector. And return y = [2 8 18 32 50]';
Right now I have the code:
N = length(x);
for i=1:N
y(i,:) = (i*2).*x(i,:);
end
I've new to Matlab so I've been doing research to try and learn the syntax that will let me do element by element multiplication and all that but it's been difficult. I can't get past that 1:numel(x) takes the place of my i. Again I'm new to matlab so any explanation on the answers that will help me learn is greatly appreciated. Thanks!