help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Curve fitting of data from text file


From: Przemek Klosowski
Subject: Re: Curve fitting of data from text file
Date: Wed, 31 Mar 2010 11:27:04 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Thunderbird/3.0.3

On 03/30/2010 05:20 PM, address@hidden wrote:
Hello,
After employing the "leasqr" function the way suggested by you how can I plot 
and show both the fitted and original curve?

Also how can I specify the initial guess a and b if I want to specify as a 
range (ex: a between 25 to 2500) similarly b also.

I am glad it works for you. To plot, you can do this:

yfit=leasqr(V_g,I_d,[1 1],@(x,p)(p(1).*(x-p(2)).^2))
plot(V_g,I_d,'+',V_g,yfit)

which should plot your data points with crosses, and your fitted function with lines. Check 'help leasqr' for details.
In particular, the initial values of parameters are given by the
third argument to leasqr ([1 1] in the above example).

leasqr doesn't seem to allow constraining parameters, but you can
sneak them in by penalizing your function if parameters
are out of bounds; just add a term like 1000*((p(1)<25)||(p(1)>2500))

Please send your query to address@hidden other people
will have better ideas there.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]