Filter löschen
Filter löschen

Calculating dt inside a function

12 Ansichten (letzte 30 Tage)
Chris
Chris am 11 Feb. 2013
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.
  1 Kommentar
Azzi Abdelmalek
Azzi Abdelmalek am 11 Feb. 2013
Is it a function? if yes post its arguments

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Doug Hull
Doug Hull am 11 Feb. 2013
Can you pass told into the function?
If not, persistent might help you.
Look into the properties of functions and subfunctions here:
  1 Kommentar
Chris
Chris am 12 Feb. 2013
The persistent declaration did it. Thanks for your help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by