comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Least Square
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Least Square [message #9717 is a reply to message #9714] Thu, 07 August 1997 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
R.J. Hall wrote:
>
> Dear all,
>
> I was windering if the following can be solced using IDL (V4)
>
> Data:- Change in voltage against time
>
> Result:- Sinusoidal wave
>
> Is it possible to find the line of best fit, and thus derive its
> equation using IDL?
>
> The form of the equation is as follows:-
>
> y = a * sin (b*x + c)
>
> Many thanks in advance
>
> Richard

You can use curvefit() as follows

Result = CURVEFIT(time, voltage, Weights, A, FUNCTION_NAME='sinfunc')

Weights can be replicate(1.0,n_elements(time)) if there is no
weighting.
A is a vector of your parameters ... A=[a,b,c], set to an initial guess.
and sinfunc must be a function as follows:

function sinfunc,time, A, funcval, pder
s=sin(A[1]*time+A[2])
funcval=A[0]*s
IF N_PARAMS() GE 4 THEN BEGIN
cfac=funcval*cos(A[1]*time+A[2])
pder=[s,time*cfac, cfac]
ENDIF
end
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Share memory between C and IDL-RPC-server?
Next Topic: Re: delete a tagname from a structure?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:25:32 PDT 2025

Total time taken to generate the page: 0.00464 seconds