MATLAB: Nonlinear least-squares data fit

curve fittingMATLAB

I am trying to make a data fit for the data attached to this post,Nu=f(Re,Theta,Beta).I use lsqnonlin(fun,x0) function for this purpose.I have created a script file for this fitting,but everytime I try to run the script,the program always shows error messages.So,what is the problem with this script.
clc
clear all
% Create an anonymous function that describes the expected relationship
% between X and Y
f=@(c,x) c(1).*(x(:,1).^c(2)).*(x(:,2).^c(3)).*(x(:,3).^c(4))./x(:,4)-1;
% data set
% Specify x variables from data file,Re,Theta and Beta columns.
x=xlsread('all data for fitting');
% Specify y variable from data file ,(Nu)column.
y=x(:,4);
% Specify a vector of starting conditions for the solvers
c0=[1;1;1;1];
% Perform a nonlinear regression
c=lsqnonlin(f,c0);

Best Answer

The objective function needs to be coded as:
ffcn = @(c) f(c,x) - y;
with the complete lsqnonlin call being:
f=@(c,x) c(1).*(x(:,1).^c(2)).*(x(:,2).^c(3)).*(x(:,3).^c(4))./x(:,4)-1;
ffcn = @(c) f(c,x) - y;
c0=[1;1;1;1];
C = lsqnonlin(ffcn, c0);
producing:
C =
1.0308e-01
1.3246e+00
1.9801e-06
-4.6017e-01
.