i want to resolve this equation in matlab:
I have do it with:
But now i have two problems:
First i want stop the plot when i give a time, for example t=pi, but if i write t0=[0,pi] the plot is wrong.
After, i want that when y(2)=0 the plot stop, and it will appear a semicircle, but i can't do it :S.
Try use logical indexing. I am not familiar with ODE45 so there might be a nicer way to do this but in terms of plotting you could try this.
The plot I get is only a quadrant tho so you might need to play with the code a bit. I did not fully understand your question so I hope that helps a bit.
Lind = (y(:,2) < 0 & t < pi);%use logical indexing
also there is no need to use "double" when defining variables. All variables typed into the workspace are doubles by default. You can check this with the "whos" command.
EDU>> a = 1.06
EDU>> b = 1
Name Size Bytes Class Attributes
a 1x1 8 double
b 1x1 8 double
But...this is a "small trap", no?
I mean, i want to plot the graphic until y(2)=0...but here you say that i plot all the graphic and only i show one quadrant, no?
I have other problem...(i do it how you say me, thanks!).
I have other differential equations:
dx = y(4)+y(2);
dy = y(5)-y(1);
dz = y(6);
dpx = y(5) - ((1-mu)/(r1.^3))*(y(1)-mu) - (mu/(r2.^3))*(y(1)-mu+1);
dpy = -y(4) -((1-mu)/(r1.^3) + mu/(r2.^3))*y(2);
dpz = -((1-mu)/(r1.^3) + mu/(r2.^3))*y(2);
and i want to resolve the system, i do:
[t,y]= ode45('test2',tf, cond_initials);
but, i want plot this..."y" have 6 columns...i want to do something like that:
but it is wrong...what can i do?
thank you very much!
What is it you want to plot in the first instance? Is it the function against time? Because if so, that's not what you're doing. You're plotting the results of the two equations against each other when you should be plotting the result of the appropriate equation against time.
Originally Posted by darii
Secondly, I'm not sure that you can stop ODE45 using a particular condition. ODE45 runs through the time interval that you give it, and I'm not sure you can stop it given a particular condition without editing the code for ODE45.
I wouldn't recommending attempting to plot in 6 dimensions lol :S. The plot command is for plotting in 2 dimensions. You must use mesh, contour, surf or plot3 to plot in three dimensions... and I don't reckon you're able to plot in anything more than that!
Originally Posted by darii
I have to plot the function projected in (x,y), for that i are plotting the results.
After, i have to integrate until y=0, but i don't know how do it.
And...for the 6 equations, it is the same, but i can't do it :S
I just saw that with "events" in ode45 could be posible integrate until y=0.
Somebody has used events? because i never did it