MATLAB: Recursion Limit reachd

recursion limitsplinefit

I want to fit a data set with a cubic spline. I'm using the code that you can find at this link: http://www.mathworks.com/matlabcentral/fileexchange/13812-splinefit
I modified the first part with:
function pp = splinefit(varargin)
x = 'energy_keV';
y = 'total_w_coh';
pp = splinefit(x,y,4);
and I have this error message:
??? Maximum recursion limit of 1000 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Error in ==> splinefit
I've changed the limit but it's always the same. What is better to do?

Best Answer

Your function is called "splinefit" and it calls a function, which is called "splinefit". Most likely you want another name for your function, such that the function SPLINEFIT is not shadowed.
But it is very strange that you try to fit the strings 'energy_keV' and 'total_w_coh' ! I assume you want to use these strings as names of variables. But this far away from beeing valid Matlab syntax. Therefore I strongly recommend to read the Getting Started chapters in the documentation.
Maybe you want this:
pp = splinefit(energy_keV, total_w_coh, 4);