Help recursive function matlab code

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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Report Generator についてさらに検索

タグ

質問済み:

2015 年 4 月 28 日

編集済み:

2015 年 5 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by