Home Issue with plotting in MATLAB (using ode45)
Reply: 2

Issue with plotting in MATLAB (using ode45)

JordanSW Published in 2018-01-12 15:53:08Z

Alright so i want to plot the right side as a function of N using this equation:


I'm using MATLAB and my problem is that the plot stops at an x value of 200.

I'm using the following code:

T = 1000;

eq = @(t,N)(-0.5*N+100);

[t,N] = ode45(eq,[0 500],-5);


axis([0 1000 -500 500])

Is there any way I can get my graph to continue to an x value of 1000?

am304 Reply to 2018-01-12 15:58:59Z

That's because you're only solving the ode on the interval [0 500] (see the second argument you pass to the ode45 function). To plot it on a different interval, you first need to solve it on a different interval:

T = 1000;
eq = @(t,N)(-0.5*N+100);
[t,N] = ode45(eq,[0 1000],-5); % second argument changed to solve on different interval
axis([0 1000 -500 500])
Mehrdad Zandigohar
Mehrdad Zandigohar Reply to 2018-01-13 08:20:26Z

That's because N converges to 200 after some time, as you can see the plot below:

So there will be no value more than 200 and when you want to plot dN/dt vs. N your x axis will be from 0 to 200.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309366 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO