first I was thinking it was very easy to obtain a variable's or function's value after each step within ode45 subfunction. But just yesterday I found out all I had done before might be incorrect! just see the MATLAB code below:(adsbygoogle = window.adsbygoogle || []).push({});

I believed the two plots should be exactly the same but they are not! I am very disappointed and confused! can someone explain why they are not the same? and if t2 and F2 are not the actual values after each step, how can I obtain actual values of variable (t) and function (F) after each step?

many thanks in advance,

Ashkan

function tdelay

clear

clc

global Fd ts i F2 t2

Fd=8;

F0=5;

ts=0.01;

i=1;

% F=(F0-Fd)*exp(-t./ts)+Fd;

[t,F]=ode45(@werely,[0 1],F0);

plot(t,F)

hold on

plot(t2,F2,'r')

end

function dF=werely(t,F)

global ts Fd i t2 F2

t2(i)=t;

F2(i)=F;

dF=(1/ts)*(-F+Fd);

i=i+1;

end

**Physics Forums - The Fusion of Science and Community**

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 access function's (and variable's) value in ODE45 right after each step?

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - access function's variable's | Date |
---|---|

Mathematica Cannot do the integral of the Hyper-geometric function? | Mar 11, 2018 |

Matlab fails to access a list of variables | Jun 30, 2013 |

CST - Access CSTResultReader.dll from EXCEL VBA | Nov 8, 2012 |

VBA with Access and Excel Help | Dec 20, 2011 |

Accessibility (alt tags) for LaTeX, graphviz | Aug 23, 2010 |

**Physics Forums - The Fusion of Science and Community**