How do i use the nlinfit function when there are two independent variables?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Himaja
am 23 Jun. 2014
Kommentiert: Star Strider
am 26 Dez. 2020
v0=b(1).*A.*B/((b(2).*b(3))+(b(3).*A)+(A.*B))
This is my model. I have two independent variables A and B.v0 is the dependent variable. Now can you please help me with writing the line code for this in matlab where i have to use a nlinfit function.
For one independent variable the following code worked:
model=@(b,x) b(1).*substrate./(b(2)+substrate);
initialguess=[1 1];
[beta,R,J,CovB,MSE] = nlinfit(substrate,vo,model, initialguess);
I want to do the same thing for my above equation.Please suggest.
THANK YOU.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 23 Jun. 2014
You have to pass your independent variable as a single value. If you have two independent variables, simply create a matrix from them, and make corresponding changes in your function:
AB = [A B]; % Assumes A and B are COLUMN vectors
v0=b(1).*AB(:,1).*AB(:,2)/((b(2).*b(3))+(b(3).*AB(:,1))+(AB(:,1).*AB(:,2)))
Make appropriate changes if they are row vectors, or simply transpose the row vectors to column vectors. (The nlinfit function doesn’t care. It just wants your function to return a vector that matches your dependent variable vector dimensions.)
Your call to nlinfit then becomes:
[beta,R,J,CovB,MSE] = nlinfit(AB, ...
0 Kommentare
Weitere Antworten (1)
Himaja
am 24 Jun. 2014
Bearbeitet: Himaja
am 24 Jun. 2014
3 Kommentare
GAGANDEEP KAUR
am 26 Dez. 2020
May I please get some suggestion for multivariable output case. As I have 1 input variable(say mole fraction x) and 9 outputs e.g. say activity coefficient of 9 species yk1,yk2,yk3.........yk9, are in form of vactors, that are obtained and has to be fitted to obtain unknown parameters
Star Strider
am 26 Dez. 2020
GAGANDEEP KAUR —
The nlinfit function cannot (to my knowledge) fit more than 1 dependent variable. However, the lsqcurvefit function can.
Some restrictrions remain with respect to lsqcurvefit however, since confidence intervals on the parameters are possible with more than 1 dependent variable and only with unconstrained parameter estimates with nlparci, although it is not possible to calculate confidence intervals on the fit with more than 1 dependent variable with nlpredci.
Siehe auch
Kategorien
Mehr zu Disk-Based Gain and Phase Margins finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!