Effacer les filtres
Effacer les filtres

Calculating dt inside a function

12 vues (au cours des 30 derniers jours)
Chris
Chris le 11 Fév 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 commentaire
Azzi Abdelmalek
Azzi Abdelmalek le 11 Fév 2013
Is it a function? if yes post its arguments

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by