Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to use the function 'nlinfit' in matlab?

Status
Not open for further replies.

melodyseu

Junior Member level 3
Junior Member level 3
Joined
Jul 22, 2004
Messages
31
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
233
nlinfit

I'm dealing with the curve-fitting using the function--nlinfit in matlab.
Here is the syntax : beta = nlinfit(X,y,'model',beta0), and I don't know how to define the term 'model'.
Can you give me some advice,thanks.
 

nlinfit example

Hi there,

You need to define your 'model' as a function (possibly in a seperate m-file). For example

>>beta = nlinfit(X,y,myfun,beta0)

where MYFUN is a MATLAB function such as:
function yhat = myfun(beta, X)
b1 = beta(1);
b2 = beta(2);
yhat = 1 ./ (1 + exp(b1 + b2*X));


MYFUN can also be an inline object:
fun = inline('1 ./ (1 + exp(b(1) + b(2*x))', 'b', 'x')
nlinfit(x, y, fun, b0)

HTH :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top