Hi everyone,(adsbygoogle = window.adsbygoogle || []).push({});

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?")

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# How to follow a function's value in ODE45 Matlab?

Loading...

Similar Threads for follow function's value |
---|

MATLAB Coding up the step function |

Bi-exponential function fitting in Origin Lab SW |

Mathematica Looping through vectorized functions for a piecewise solution |

Mathematica Cannot do the integral of the Hyper-geometric function? |

Mathematica Cannot Plot This Function in Mathematica |

**Physics Forums | Science Articles, Homework Help, Discussion**