Problem in using nlinfit?

3 vues (au cours des 30 derniers jours)
Sameer
Sameer le 22 Juil 2014
Commenté : Star Strider le 23 Juil 2014
Hello all
I want to use a nlinfit, previously I used for two inputs and it was working fine but not I have 3 inputs and its giving error:
??? Error using ==> statset at 262
Expected argument 2 to be a parameter name string or an options structure
created with STATSET.
Error in ==> nlinfit at 103
options = statset(statset('nlinfit'), options);
Error in ==> Nu_variables at 9
param=nlinfit(Re,Pr,Nu,@fitfun_Nu,param0);
Error in ==> tem_dep_cal at 42
h=Nu_variables(Re,Pr,Nu);
where my fitfun is:
function [ Nu ] = fitfun_Nu(param,Re,Pr)
Nu=param(1).*(Re.^param(2)).*(Pr.^param(3));
end
can anyone guide me to rectify the error?
Thanking you!!!
Regards

Réponse acceptée

Star Strider
Star Strider le 22 Juil 2014
You can pass two independent variables to your function but you have to combine them into one array. Assuming Re and Pr are both column vectors, the array for them becomes:
RePr = [Re Pr];
your function becomes:
function [ Nu ] = fitfun_Nu(param,RePr)
Nu=param(1).*(RePr(:,1).^param(2)).*(RePr(:,2).^param(3));
end
and the call to nlinfit becomes:
param=nlinfit(RePr,Nu,@fitfun_Nu,param0);
That should work.
  2 commentaires
Sameer
Sameer le 23 Juil 2014
Hi...Thank you!!!
Star Strider
Star Strider le 23 Juil 2014
My pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by