Hello all! I'm trying to solve a structural vibration problem using ode113. Its outputs are time and a 2D matrix with displacements of the various modal coordinates. However, I'm trying to do an ensemble average of responses for various harmonic inputs, so I'm looping through ode113 "Nsig" times, where Nsig is the number of harmonic inputs I'm using. Right now, my script looks like a monster, using way too many instances of "eval" to create and analyze the variable sets that I need to extract the ensemble averages. The line that I really need help with is:
eval(['[t,ass' num2str(j) ']=ode113(@(t,ass' num2str(j) ')nlsmsysf(t,ass' num2str(j) ',Mm,M0,ks,zmv,alpha,nv,mv,omegmv,lx,ly,x0,y0,xF,yF,T,tss,omegmin,omegmax,Ar,phir),tspan,a0);'])
This is inside of a "for" loop bounded from 1:j. It works, but it's clumsy and slow, especially if I'm running 30 signals or large amounts of data. What I'd like to do is:
[t,ass(:,:,j)]=ode113(@(t,ass)nlsmsysf(t,ass(:,:,j),Mm,M0,ks,zmv,alpha,nv,mv,omegmv,lx,ly,x0,y0,xF,yF,T,tss,omegmin,omegmax,Ar,phir),tspan,a0);
This is also inside of the same for loop. It works for the first iteration, but the second time around, I get an "index exceeds matrix dimensions" error. Anybody see a fix? Thank you so much for your help!
Best Answer