Rescursion Limit Reach?

1 vue (au cours des 30 derniers jours)
Big Meech
Big Meech le 26 Avr 2011
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

Réponses (1)

Paulo Silva
Paulo Silva le 26 Avr 2011
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 commentaires
Big Meech
Big Meech le 26 Avr 2011
I was suppose to write another function (to graph) that uses the function I already have above in the same .m file.
Paulo Silva
Paulo Silva le 26 Avr 2011
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by