I think I'm having problems on getting anonymous functions working correctly. I've read the documentation a few times and googled but I can't see what I am doing wrong. Any help will be very appreciated.
I have a program that is suposed to fit a bunch of values with leasqr. The function that leasqr should use for fitting takes as argument some preprocess values. However, leasqr only accepts functions that have f(x,p) as it argument. My idea was to make an anonymous function with those as arguments and which would already have the preprocess inside. Here's my code
------------------------------------------------------------------------------------------------------------------ ## Up to here is all the preprocess which I'm not copying to make it simple ## but if you think it may the problem just ask
preProcess{1} = nr/distance; preProcess{2} = J1wxi; preProcess{3} = alf2; preProcess{4} = U;
#Df is the parameter to adjust # func_PureDiffusion is in a .m file func_PureDiffusion_for_leasqr = @(timestamps,Df) func_PureDiffusion(timestamps, Df, preProcess);
## Avoid assignment of physical irrelevant parameters by fitting routine
if (Df < 0 || Df > 800) frap = -100*ones(size(tList)); return end
## Time points have to be stored in a a row vector if (size(tList,2)==1) tList = tList'; end
## Calculate the FRAP recovery curve
ea = exp(-Df*alf2*tList); # Exponential decay in Eq.(S.19) frap = 2*(RNrel)*(U.*J1wxi)'*ea; # Eq.(S.22) frap = frap'; # Transform to a column vector ------------------------------------------------------------------------------------------------------------------
And here's the error I get
------------------------------------------------------------------------------------------------------------------
error: error creating function handle "@func_PureDiffusion_for_regression" error: evaluating argument list element number 4 error: evaluating argument list element number 1 error: called from: ## This is the line with the leasqr function
------------------------------------------------------------------------------------------------------------------