Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: loop funtion
Replies: 2   Last Post: Jul 25, 2013 9:34 AM

 Messages: [ Previous | Next ]
 Tyson Posts: 1 Registered: 7/25/13
loop funtion
Posted: Jul 25, 2013 6:17 AM

I've been posed the following:
Given a 6x6 real matrix, A, and a column vector, v use MATLAB to calculate,
a) A*v
b) ||A*v||
c) u=(A*v)/(||A*v||)
d) reassign v to equal u
e) repeat steps (a) through (d) a total of fifteen times.

This is what I've got so far but it doesn't seem to work,

A = [6 1 1 1 1 1;1 7 0 1 1 1;1 0 8 1 1 1;1 1 1 9 1 1;1 1 1 1 10 1;1 1 1 1 1 1]
v(1) = [1; 0; 0; 0; 0; 0]
for n = 1:15
A*v(n)
norm(A*v(n))
u = (A*v(n))/(norm(A*v(n)))
clear v(n)
v(n) = u
clear u
end

MATLAB tells me "In an assignment A(I) = B, the number of elements in B and I must be the same."

Date Subject Author
7/25/13 Tyson
7/25/13 Nasser Abbasi
7/25/13 Steven Lord