Hi good people,
I'm trying to solve this:
clcclear allclose allx0=0;xdot0=0;IC=[x0 xdot0];t=0:0.1:10;[t,x]=ode45( @MDOF1, t, IC );
when the MDOF1 function looks like:
function dxdt=MDOF1(t,x)m=[2 2];M=diag(m);C=[4 -2;-2 4];K=[8 -4;-4 8];F=10*sin(10*t);dxdt(1)=x(2);dxdt(2)=inv(M)*F-(inv(M)*C)*x(2)-(inv(M)*K)*x(1)dxdt=[dxdt(1);dxdt(2)]; end
and i get this error:
Unable to perform assignment because the left and right sides have a different number of elements.Error in MDOF1 (line 8)dxdt(2)=inv(M)*F-(inv(M)*C)*x(2)-(inv(M)*K)*x(1)Error in odearguments (line 90)f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);Error in mdof1_ode (line 8)[t,x]=ode45( @MDOF1, t, IC );
Could anyone advise me what I'm doing wrong?
Best Answer