MATLAB: How to go around infinite recursions

function bypassinginfinite recursion

Hi. I have a series of functions that go Weight_Approx_1 -> Geometric_Approx -> Weight_Approx_2 . I would like for the Weight_Approx_2 to feed back in to Weight_Approx_1 so it can act as the new input. I can do this so well that I get an infinite loop without trying. How do I get a loop like this to return a final value from the Weight_Approx_2 program after a number of iterations I choose?
In other words, how do I rewrite a series of functions like below such that I control how many times f_c gets run? Once int == 2, it'll just be an infinite loop
function a = fa
for int = (1:10)
if int = 1
a = 1;
else
a = fc;
end
end
end
function b = fb
b = fa*2
end
function c = fc
c = fb + 1;
end

Best Answer

I just redesigned the whole program for this program to work.