MATLAB: Error

matrix

A = [ 0 0 0.43; 0.6 0 0; 0 0.75 0.96 ];
T = [ 1 2 3 4 5 10 20 25 50 75 ];
V0 = [ 42, 0, 95 ]';
V=zeros(3,length(T));
V(:,1)=V0;
i=0;
for t=T
i=i+1;
V(:,1)=(A^t)*V0;
end
figure
T=[0 1 2 3 4 5 10 20 25 50 75];
T2=log(T);
V2=log(V);
LINE 22 plot( T2, V2(1,:), 'b', T2, V2(2,:), 'g', T2, V2(3,:), 'r')
%legend('calves','yearlings','adults')
title('population versus time')
xlabel('time')
LINE 30 ylabel('population')
THAT ERROR WENT AWAY. NOW IT SAYS….
??? Error using ==> plot Vectors must be the same lengths.
Error in ==> project3 at 22 plot( T2, V2(1,:), 'b', T2, V2(2,:), 'g', T2, V2(3,:), 'r')

Best Answer

Which is line 48? Please show the traceback.
Image Analyst has proposed (A.^t)*V0 but I think you do want (A^t)*V0 . An array raised to a power is appropriate for a stocastic process. However, when you raise a 3 x 3 matrix to a power, you get out a 3 x 3 matrix. You then try to multiply that by a 1 x 3 matrix, which is going to be an error. I think your definition of V0 should not have the transpose at the end, and should just be
V0 = [ 42; 0; 95 ];