Rescursion Limit Reach?
1 次查看(过去 30 天)
显示 更早的评论
When I try to run so I call values spring(200,10000,15000,0.1) I keep getting a Rescursion Error message. When I set the recursion level higher MatLab crashes. Any ideas how I can fix this. Code below: function x=spring(W,k1,k2,d) if ((W/k1)<d) x= W/k1; else x=(W + 2*d*k2)/(k1 + 2*k2); end
clf %clears the current figure window
hold on %creates new axes
st=5; %step by 5
for W=0+st:st:3000-st;% W is between 0 and 3000 and creates a loop
x= spring(W,k1,k2,d);
plot(W,x)
end
0 个评论
回答(1 个)
Paulo Silva
2011-4-26
You have the spring function inside one m file called spring.m and the script that calls the spring function inside another file called something else? you run the script and you get the error about the recursion?! you are calling the spring function inside itself for sure, don't do that.
2 个评论
Paulo Silva
2011-4-26
That won't work, the function you made is called from the outside so you must have another script or function that calls the spring function.
I'm going to post a better code in your other Question, that code you are using was just to show a simple way to do it, it's very inefficient.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!