When I execute this code, instead of an intended 12×6 matrix "u" made from u(1), u(2), u(3), etc., I end up with a single 12×1 vector "u", as u gets overwritten each pass.
for i = 1:12; o = omega(i);M = [(-o^2*m(1)+k(1)+k(2)), -k(2), 0, 0, 0, 0; -k(2), (-o^2*m(2)+k(2)+k(3)), -k(3), 0, 0, 0; 0, -k(3), (-o^2*m(3)+k(3)+k(4)), -k(4), 0, 0; 0, 0, -k(4), (-o^2*m(4)+k(4)+k(5)), -k(5), 0;0, 0, 0, -k(5), (-o^2*m(5)+k(5)+k(6)), -k(6); 0, 0, 0, 0, -k(6), (-o^2*m(6)+k(6)+k(7))];u(i)= eig(M);end
where omega is a 12×1 vector.
What's wrong with the code?
Best Answer