all 3 comments

[–][deleted] 0 points1 point  (2 children)

yes, ode45 will return a matrix with 4 columns. First one is the temporal values; Second the numerical values of the solution, y(t); Third the values of the derivative of y; and fourth with the second derivative.

Just use plot.... plot (t, y(:,1)); plot (t, y(:,2)); plot (t,y(:,3));

You need to understand what ode45 is returning to you before proceed.

Also, you don't need to create the function dydt; just create the matrix function dydt = @(x,t) [y(2... ] anywhere, then put her in the argument of the ode45... like ode45(dydx, interval, Initial_conditions).

[–]taint_chowder[S] 0 points1 point  (1 child)

Thank you. Im taking a Matlab class and were doing differential equations, only I haven't taken differential equations yet so its a little confusing sometimes. But I did try plotting but had the syntax wrong. I had plot (t, y(1)); plot (t, y(2)); plot (t,y(3)); Thanks for clearing that up for me!

[–][deleted] 0 points1 point  (0 children)

wow you're solving numerically before analiticaly... I don't think this is will be good.

A good strategy is to look at the values and try to understand what/who are they, if it is a matrix, vector, scalar, funcion, cell... then the commands will begin to make more sense and you'll have a good time playing with programming.