Calculating dt inside a function

조회 수: 5 (최근 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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by