- #1
t-gas
- 3
- 0
Hi everyone,
It is extremely helpful for me if you could answer the following question. I hope it is a relatively simple problem:
I just need a plot or an output data file of the values of the function 'm=2/y(1)' appearing in the function 'myfun' for each time-step. This is extremely easy in other programming languanges but in Matlab when I plot(t,m) it only returns the value at the end of the integration.
%%%%%%%%%%
function manoura;
tspan = [0 0.8];
y0 = [3; 7/3];
[T, Y] = ode45(@myfun, tspan, y0);
subplot(211); plot(T,Y(:,1));
subplot(212); plot(T,Y(:,2));
function F1 = myfun(t,y);
m=2/y(1);
F1 = [y(2); m*y(2) - 4*y(1) + (t+2)*exp(-2*t)];
%%%%%%%%%
Thank you in advance!
I have tried everywhere and I cannot find a solution.
Thank you in advance!
(I have already posted it as "How to follow a function's value in ODE45 Matlab?")
It is extremely helpful for me if you could answer the following question. I hope it is a relatively simple problem:
I just need a plot or an output data file of the values of the function 'm=2/y(1)' appearing in the function 'myfun' for each time-step. This is extremely easy in other programming languanges but in Matlab when I plot(t,m) it only returns the value at the end of the integration.
%%%%%%%%%%
function manoura;
tspan = [0 0.8];
y0 = [3; 7/3];
[T, Y] = ode45(@myfun, tspan, y0);
subplot(211); plot(T,Y(:,1));
subplot(212); plot(T,Y(:,2));
function F1 = myfun(t,y);
m=2/y(1);
F1 = [y(2); m*y(2) - 4*y(1) + (t+2)*exp(-2*t)];
%%%%%%%%%
Thank you in advance!
I have tried everywhere and I cannot find a solution.
Thank you in advance!
(I have already posted it as "How to follow a function's value in ODE45 Matlab?")