Efficient MATLAB Code for Recursive Functions: Expert Tips and Tricks

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 3K views
EngWiPy
Messages
1,361
Reaction score
61
Hello,

I have the following equation, and I want to program it using MATLAB. But it is a recursive function, and it seems that I can not handle it well. So please if anyone can help, I will be thankful.

attachment.php?attachmentid=19240&stc=1&d=1244335353.jpg
 

Attachments

  • ExpansionFactor.JPG
    ExpansionFactor.JPG
    10.8 KB · Views: 3,867
Physics news on Phys.org
I would suggest you create a 2D matrix of size k (whatever that happens to be / you choose it to be--maybe this is a parameter that your function takes in?), seed the initial values given, and then make copious use of the for or while loops in MATLAB:
http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-1931.html#brbsthm
http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-1931.html#brbstiw-1
 
Last edited by a moderator: