Calculating dt inside a function

8 次查看(过去 30 天)
I want to calculate dt inside a function whose variable is t. I try doing as follows:
if t> 0
dt = t - told
end
told = t
inside the function but I receive the error "undefined variable or function 'told'". Is there a command that will store 'told' to be used at the next time step for the function or am I going about it the wrong way.

采纳的回答

Doug Hull
Doug Hull 2013-2-11
Can you pass told into the function?
If not, persistent might help you.
Look into the properties of functions and subfunctions here:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by