hi am still getting a hang of MATLAB havent been using it for so long and i keep getting an error message about 'The size of the indicated variable or array appears to be changing with each loop iteration.' been trying to fix this with no luck. i am doing a free vibration analysis of a 2 dof cantilever beam may i get help with my code. below is my whole script
m1=53;% Mass
m2=62.096;k=3.096e+006 ; % Stiffness
c=150; % Damping
% 4 x 4 matrices
disp('4 x 4 Mass matrix');mt=[c,0,m1,0;0,0,0,m2;m1,0,0,0;0,m2,0,0];disp('4 x 4 stiffness matrix');kt=[-m1,0,0,0;0,m2,0,0;0,0,3*k,-2*k;0,0,-2*k,2*k];Z=mt\kt;[V,D]=eig(Z);disp('Eigenvalues');V;disp('Initial conditions');x0=[0;0;0.005;0];disp('Integration constants');S=V\x0;tk=linspace(0,2,101);% Evaluation of time dependent response
% Recall that x1=y3 and x2=y4
for k=1:101 t=tk(k); for i=3:4 x(k,i-2)=0; for j=1:4 x(k,i-2)=0;x(k,i-2)=x(k,i-2)+(real(S(j))*real(V(i,j))-imag(S(j))*imag(V(i,j)))*cos(imag(D(j,j))*t);x(k,i-2)=x(k,i-2)+(imag(S(j))*real(V(i,j))-real(S(j))*imag(V(i,j)))*sin(imag(V(i,j))*t); x(k,i-2)=x(k,i-2)*exp(-real(D(j,j))*t); end endendplot(tk,x(:,1),'-',tk,x(:,2),':')title('free vibration of a viscously damped 2 DOF')xlabel('t[sec]')ylabel('x(m)')legend('x1(t)','x2(t)')
Best Answer