From: Brendan on 25 Mar 2010 13:57 Hi, I have a for loop that calculates the position of a planet rotating about the sun. It uses ode45 and in iteration of the loop, calculates 11 values of x, y, xdot and ydot. This is done by initializing initial conditions and then resetting the initial conditions as the final conditions(11th) of each iteration of the loop. The code is as follows: y0 = [1;0;0;1]; z0 = [1.523;0;0;0.802]; w0=[1;0;0;1.09]; t0=0 tend=.1 step=tend/0.01 options=odeset('RelTol',1.e-7, 'AbsTol',1.e-9); for i=1:60 [t,z]=ode45(@twobodyfunctionmars,[0:0.01:tend],z0,options); [t,w]=ode45(@twobodyspacecraftfunction,[0:0.01:tend],w0,options); [t,y]=ode45(@twobodyfunctionearth,[0:0.01:tend],y0,options); rectangle('Position',[-0.25,-0.25,0.5,0.5],'Curvature',[1,1],'Facecolor','y') daspect ([1,1,1]) plot(y(:,1),y(:,2),'-b') plot(w(:,1),w(:,2), '-g') plot(z(:,1),z(:,2),'-r') axis ([-2 2 -2 2]) grid on drawnow y0=[y(step,1);y(step,2);y(step,3);y(step,4)]; z0=[z(step,1);z(step,2);z(step,3);z(step,4)]; w0=[w(step,1);w(step,2);w(step,3);w(step,4)]; end hold off Where initial conditions y0=[x y xdot ydot], same for z0 and w0. My problem is that I can only manipulate the data of the final eleven valuues from the last iteration of the for loop. Im trying to concatenate each set of 11 values into a 4-d matrix conataining all values calculated over the entire loop. Could someone tell me a way of doing this so that I have all the values in one matrix that I can access and manipulate?? Thanks Brendan.
|
Pages: 1 Prev: dynamic regexp Next: What are the functions to apply an analog and a discrete-time fir |