I'm trying to use the nlinfit that matlab has to fit a sinc^2 function, but it keeps telling me that my coefficients have the wrong inputs. Here's basically what I am doing.(adsbygoogle = window.adsbygoogle || []).push({});

%driver.m

y = [intensity points]; %I actually have a bunch of intensity points, but I don't want to list them

x = [data points]; %data points relating to intensity

plot(x,y,'o')

hold on

[beta,r,J,sigma] = nlinfit(x,y,@sincsq, beta);

beta

r

J

sigma

plot(x,sincsq(beta,x),'-k')

and I have the function sincsq defined as

%sinc^2 model for passing to the nlinear fit

function yhat = sincsq(beta,x)

yhat = beta(1).*sinc(beta(2).*x(1,.^2;

The exact error message when I run the first file is:

Error using ==> beta at 21

Not enough input arguments

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab nlinfit

**Physics Forums | Science Articles, Homework Help, Discussion**