Hi there, I am trying to understand an in class example put am having difficulties completing the code the question is :
In the command window, use a for loop to fill a vector v with the squares of 2, 3, 4, 5. Start with
v = zeros(1,4)
After entering your for loop in the command window, v should be:
>> v v=4 9 16 25
Heres what I have so far:
>> v=zeros(1,4);i=1;v(i)=2;i=2;v(i)=3;i=3;v(i)=4i=4;v(i)=5;v = 2 3 4 5 for i=1:4 v=v(i).*v(i); disp(v); end;
however I am getting the message "Index exceeds matrix dimensions."
Can someone offer me some tips with approaching this problem
Best Answer