undefined input argument using nlinfit

1 view (last 30 days)
Hi! i am using an nlinfit to determine a model parameter but i kept getting this error:
Input argument "data" is undefined.
even though i already defined the argument data. For clarity i will post the syntax here:
%input data;
%data [T(K) B(m3/gmol)];
data=[330 -9.7707
370 -7.3893
410 -5.6488
450 -4.3256
490 -3.2880
530 -2.4538
570 -1.7695
610 -1.1984
650 -0.71487
690 -0.30045
730 0.058557];
Gc=83.1451e-6;
Bact=data(:,2)
Tact=data(:,1)
unk0=[374 0.1 16]; %[Tc w Pc] in order, initial guess;
[unkhat resid J]=nlinfit(data,Bact,pct,unk0);
unkhat
the function pct is defined on a separate m-file.
is there anything i missed that i kept geting that error? i will gladly appreciate your help. thank you.

Accepted Answer

the cyclist
the cyclist on 25 Jun 2011
Marineil,
I am confused a bit by your code. Because you did not include your definition of "pct", I created a simple one. When I do that, I do not get any error about the input parameter "data". I do get a warning about the resulting Jacobian, but I think that is because one of your X columns is defined as exactly the same as your Y column, in the call to nlinfit(). [I am wondering if you meant to just input "Tact" as the first argument to nlinfit(), rather than the whole array "data".]
Maybe you could also post your function definition for "pct", so that we can see exactly what you are running?
  1 Comment
Marineil Gomez
Marineil Gomez on 25 Jun 2011
i apologize for not providing the m-file. this is the pct function
function [ Bcal ] = pct(unk,data)
%PCT Summary of this function goes here
% Detailed explanation goes here
Gc=83.1451e-6;
Tact=data(:,1);
F0=0.1445-(0.330./(Tact./unk(1)))-(0.1385./(Tact./unk(1)).^2)-(0.0121./(Tact./unk(1))^3)-(0.000607./(Tact./unk(1)).^8);
F1=0.0637+(0.331./(Tact./unk(1)).^2)-(0.423./(Tact./unk(1)).^3)-(0.008./(Tact./unk(1)).^8);
Bfunct=F0+unk(2).*F1;
Bcal=(Gc*unk(1).*Bfunct)./unk(3);
thanks for your help!

Sign in to comment.

More Answers (0)

Categories

Find more on Numeric Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!