help-octave
[Top][All Lists]
Advanced

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

Re: Fitting function


From: Doug Stewart
Subject: Re: Fitting function
Date: Sat, 10 Aug 2019 08:17:34 -0400



On Sat, Aug 10, 2019 at 8:01 AM mrodrig <address@hidden> wrote:
Dear Doug,

Thanks very much for your replay. Please, could you send me the solution?


OK.
You are trying to fit 2 straight lines to a set of data. Straight lines are of the form y = a*x+b. You did not have the b.


first I wrote a M file function that calculated a least-square value and returned this value.
The input to this function has to be the unknowns your R and the 2  'b's.

 Then I wrote the calling function and used the fminsearch function like this:
w=fminsearch (@q1,[R;b1;b2])
w is the resulting values for R b1 b2

Fminsearch takes the starting values for R b1 b2 and adjusts them to minimize the value returned from q1.m

I then used the calculated values and calculated a resultant y3 values and then plotted them together.

If you have more questions I will try and answer them.
Let me know If this works for you.







--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html




--
DASCertificate for 206392

Attachment: q1.m
Description: Text Data

Attachment: testq1.m
Description: Text Data


reply via email to

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