Help recursive function matlab code

2 vues (au cours des 30 derniers jours)
lady bird
lady bird le 28 Avr 2015
Modifié(e) : Thorsten le 5 Mai 2015
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

Réponse acceptée

Thorsten
Thorsten le 28 Avr 2015
Modifié(e) : Thorsten le 5 Mai 2015
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 commentaire
lady bird
lady bird le 5 Mai 2015
thank u so much Thorsten for your help

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by