Problem with plotting a function on a specified domain

I am trying to plot the solution of a system of ODEs. The code is:
tspan = [0 10];
z0 = [0.01 0.01 0.01 0.01];
[t,z] = ode45(@(t,z) odefun3(t,z), tspan, z0);
plot(z(:,3))
Why the output is plotted on the interval [0,60] and not on [0,10], as in the code ?

 Accepted Answer

You also need to specify x variable for plot. Try
plot(t, z(:,3))

2 Comments

Indeed with the command (t, z(:,3)) it worked. Thank you !

Sign in to comment.

More Answers (0)

Asked:

on 10 Jun 2018

Commented:

on 10 Jun 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!