Re: Curve fitting toolbox -- integral equation



fitModel=fittype('a.*quadgk(@(y) exp(-y.*x.*b),0,10)','ind','x')
??? Error using ==> fittype.fittype>fittype.fittype at 415
The name y cannot be used for both a coefficient and the dependent
variable.

Chad, I have two thoughts. First, the function is apparently confused by
seeing the symbol 'y' and not recognizing it as just a dummy variable in the
anonymous function definition. Second, quadgk is going to want to evaluate
this for a grid of y values that it chooses, and they may not conform with
the size of the x variable you supply, so the y.*x part I'd expect to fail.

To deal with this, I suggest putting the function into a little m file like
this:

function t=myquad(a,b,x)
t = zeros(size(x));
for j=1:numel(x)
t(j) = a.*quadgk(@(y) exp(-y.*x(j).*b),0,10);
end

Then call it as follows:

fit(x,y,fittype('myquad(a,b,x)'))

-- Tom


.