ErkNis
ErkNis

Reputation: 19

Matlab - Odeset - Odeplot

I would like to use odeplot so stepwise get the result instead of plotting the result afterwards. I've tried to write it like this but I can't get it to work so I would appreciate some help.

%Parameters

s = 1; 

q = 1; 

w = 0.1610;

y0 = [30 1 30]; % Initial values

tspan = [0 10]; % Time 0<t<10

plot=odeset('OutputFcn','odeplot');

[t, y] = ode45(@(t,y) concentration(t, y, s, q, w), plot, tspan, y0);

Upvotes: 1

Views: 1987

Answers (1)

horchler
horchler

Reputation: 18484

You need to specify your output function via an ODE Options argument:

options = odeset('OutputFcn', @odeplot);
[t, y] = ode45(@(t,y)concentration(t, y, s, q, w), tspan, y0, options);

Of course you can make your own custom output function. Type edit odeplot to see what is required (much simpler functions are possible). Also check out odephas2 and odephas3.

Upvotes: 2

Related Questions