Calculating dt inside a function

3 ビュー (過去 30 日間)
Chris
Chris 2013 年 2 月 11 日
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 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 11 日
Is it a function? if yes post its arguments

サインインしてコメントする。

採用された回答

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:
  1 件のコメント
Chris
Chris 2013 年 2 月 12 日
The persistent declaration did it. Thanks for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by