I wrote simply code blog, i want to recursive function of it. I want to like this: function [itr] = newton(x,tol)
I can't write recursive function in Matlab (Please help me)
1 次查看(过去 30 天)
显示 更早的评论
I tried many times but couldn't write a recursive function in Matlab. I don't know how to do it. My friends, I would be glad if someone could help me.
12 个评论
Rik
2020-10-24
Just because you aren't getting the help you were hoping for dosn't make this question not appropriate, so I removed your flag.
回答(1 个)
Rik
2020-10-24
In case you just want to know how to create a recursive function at all:
function n=I_call_myself(n)
disp(n)
if n>0
n=I_call_myself(n-1);
else
disp('n has reached 0')
end
end
8 个评论
Rik
2020-10-24
Sorry, once you receive an answer it is considered rude to delete it, so the system will not allow you to do that. People with a similar question might find the posts here helpful.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!