This should be a very simple question for anyone who has some experience in this area, but I'm still new to this.
I have the following system (or here is an image with better resolution):
alt text http://img199.imageshack.us/img199/2140/equation1.png
Given the following input:
u = min(2 - t/7.5, 2*(mod(t, 2) < 1));
I need to plot the output of system y.
I am describing the system with the following function:
function xprime = func(t, x)
u = min(2 - t/7.5, 2*(mod(t, 2) < 1));
xprime = [
x(2);
x(3);
0.45*u - 4*x(3)^2 - x(2)*x(1) - 4*x(2) - 2*x(1);
x(5);
sin(t) - 3*x(5)*x(1);
];
and simulating with ode23
, like this:
[tout, xout] = ode23(@func, [0 15], [1.5; 3; -0.5; 0; -1])
After the simulation, xout
will have five columns. My question is: how do I know which one is the output of the y system?
EDIT: Ok, so to put it simple, I'd like to plot the solution like this:
a = 1 % what goes here? 1, 2, 3, 4 or 5?
plot(tout, xout(:,a))
The one that corresponds to y, which appears to be x(1), of course.
If you compare your code to the equations, you can see that x(1) appears in the code every place that y appears in the equations. That would be my best guess.
[T,Y,TE,YE,IE] = ode23(odefun,tspan,y0,options)
The following table lists the output arguments for the solvers.
Isten fizesse!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With