MATLAB: Matlab error: A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval

function

hi,
i have attached my codes in the attachment. please have a look. i run 'tests.m' file. the error that i get is_
"gamma" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval.
this error is shown on line 13 of the polyblock.m.
if i dont use bisection as a function and simply call it as a script inside polyblock.m
then the same error occurs at line 73 on polyblock.m
i am confused how to solve it.

Best Answer

gamma is a function that ships with matlab. I suspect that you never intended to call that function, but instead intended to use a value that you call gamma.
However, in both your polyblock and bisection since you never create such gamma variable, matlab calls the gamma function instead every time you write something = gamma. This stops working when you try to assign a value to gamma, since you can't assign a value to a function. At this point matlab tells you: Hey, up to now you called the gamma function, now you're trying to use it as a variable. What's going on?
I can't see anywhere where you actually defined something called gamma, so I'm not clear what gamma is supposed to be.