Re: Newcomer to IDL [message #94339 is a reply to message #94337] |
Fri, 14 April 2017 02:00   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le vendredi 14 avril 2017 02:19:52 UTC+2, asma...@gmail.com a écrit :
> Hello!
>
> I would like to know why the following procedure, taken ipsis verbis from the Harris example does not compile without errors:
>
> QUOTE
>
> PRO agfunct, X, A, F, pder
> bx=EXP(A[1]*X)
> F=A[0]*bx+A[2]
> ;If the procedure is called with four parameters, calculate the
> ;partial derivatives.
> IF N_PARAMS() GE 4 THEN $
> pder=[[bx], [A[0] * X * bx], [replicate(1.0, N_ELEMENTS(X))]]
> END
> ;Compute the fit to the function we have just defined.
> ;First, define the independent and dependent variables:
> X = FLOAT(INDGEN(10))
> Y = [12.0, 11.0, 10.2, 9.4, 8.7, 8.1, 7.5, 6.9, 6.5, 6.1]
> ;Define a vector of weights.
> weights = 1.0/Y
> ;Provide an initial guess of the function’s parameters.
> A = [10.0,-0.1,2.0]
> ;Compute the parameters.
> yfit = CURVEFIT(X, Y, weights, A, SIGMA, FUNCTION_NAME='agfunct')
> ;Print the parameters returned in A.
> PRINT, 'Function parameters: ', A
> END
>
> UNQUOTE
>
> Thanks in advance,
> Antonio.
You likely made "ipsis verbis" some cute&paste from Harris documentation.
Unfirtunately, there are some non-ascii characters at the beginning of every uncommented lines (starting with bf=..., F=... and IF...) in the Agfunct subroutine, which are not accepted by the compiler.
Please remove them !
alx.
|
|
|