help-octave
[Top][All Lists]

## Re: Help in leasqr

 From: Bharath R Subject: Re: Help in leasqr Date: Fri, 26 Aug 2016 17:36:35 +0200

Hi,

Thank you very much for the clarification. I checked that some of them are redundant and I changed it. Could you please throw some light on solving differential equation to get the calculated data.? for e.g

dT/dt =((p(1)*(x(1)-T) -(p(2)*(T-x(2))))

I have to fit the T value to the measured T value. I did not find much explanation on how to solve a differential equation for parameter estimation. I look forward to hear from you.

As suggested, I am implementing nonlin_curvefit.

Thanks and regards,
Bharathy

On Fri, Aug 26, 2016 at 5:02 PM, Olaf Till wrote:
On Fri, Aug 26, 2016 at 12:17:04PM +0200, Bharath R wrote:
> Hello all,
>
> Thank you very much for such a helpful forum. I am using Octave for the
> past couple of days. I have been working to get the parameters that best
> fit my function.
>
> Function:   g=@(x,p)
> [(p(1).*p(2).*x(:,1)+(p(3).*x(:,2))+(p(4)*p(5)))./((p(1)*p(2))+p(3))]
>
> where p indicates the parameters , x indicates the independent variables
> and y is measured variable.
> [pin]=1.0000e-002
>       1.0000e+003
>       1.0000e+002
>       1.0000e-002
>       1.0000e+003
>
> [x]=21.33700    0.80000
>      21.28800    0.10000
>      20.55900   -0.80000
>      21.21800   -1.40000
>      20.68600   -1.70000
>
> [y] = 19.545
>        19.300
>        19.300
>        19.137
>        19.000
>
> When I run this function ([f, p, cvg, iter]=leasqr(x,y,pin,g)) with leasqr
> function it gives me the following result:
>
>  CONVERGENCE NOT ACHIEVED!
> f =
>
>    19.710
>    19.578
>    18.827
>    19.326
>    18.824
>
> p =
>
>   1.6953e-001
>   1.6258e+003
>   4.0087e+001
>   7.8664e-002
>   3.9346e+003
>
> cvg = 0
> iter =  20
>
> I would like to know what does "f" in result give as output. Is it giving
> me the output of function "g" after implementing the newly calculated
> parameters or is it something else? If it is the output of g, then I feel
> it is relatively closer to the measured data (y). yet it is showing "
> CONVERGENCE NOT ACHIEVED!".
>
> Also , I would like to know how do I implement a differential equation in
> leasqr to calculate the parameters. I look forward to your answer.
>
> Thanks and regards,
> Bharathy

The problem is that some of your parameters are redundant. As for your
question, the returned values should be those of the best fit achieved
so far by the algorithm. They might be almost equivalent to the
parameters, after convergence, of an equivalent problem formulated
without redundant parameters.

For the record, I recommend using nonlin_curvefit (or nonlin_residmin)