I am not understanding this indices error. Please, take a look at the code and help me with the solution. I have highlighted the line in the code in which the error is shown.
dis0=input('dis0=');disd0=input('disd0=');phi0=input('phi0=');phid0=input('phid0=');theta0=input('theta0=');thetad0=input('thetad0=');fmin=input('fmin=');fmax=input('fmax=');for f=fmin:fmax tp=1/f; dt=1/(25*f); for i=0:dt:2*tp t=i; j=i+2; f1=sin(2*pi*f*t); f2=a*sin(2*pi*f*t); f3=b*sin(2*pi*f*t); F=[f1; f2; f3]; if i==0% The error is shown in the below line.
x(j)=[dis0; phi0; theta0]; xd(j)=[disd0; phid0; thetad0]; xdd(j)=M\(F-(K*x(j))-(C*xd(j))); else break end x(j-1)=x(j)-(dt*xd(j))+(0.5*(dt^2)*xdd(j)); x(j+1)=((M/(dt^2))+(C/(2*dt)))\(F-(K-((2*M)/(dt^2)))*x(j)-((M/(dt^2))-(C/(2*dt)))*x(j-1)); endend
Best Answer