Help recursive function matlab code

조회 수: 3 (최근 30일)
lady bird
lady bird 2015년 4월 28일
편집: Thorsten 2015년 5월 5일
Hello all
Please i need your help to code a recursive function.
udisc(k)=udisk(k-1) - tau*M*sign(phi(k));
where tau & M are positive constants and phi(k) is a function
Thank you so much
Best regards

채택된 답변

Thorsten
Thorsten 2015년 4월 28일
편집: Thorsten 2015년 5월 5일
You need to know the value of udisk for one k, like k=0 to define an end of the recursion. Assuming that udisk(0) = 1, the definition is straightforward
function u = udisk(k, tau, M)
if k == 1 % replace these two lines with the
u = 1 % actual definition of udisk
else
u = udisk(k-1, tau, M) - tau*M*sign(phi(k));
end
  댓글 수: 1
lady bird
lady bird 2015년 5월 5일
thank u so much Thorsten for your help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by