- #1
Mindscrape
- 1,861
- 1
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.
%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
%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