X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 13 Mar 2006 02:06 PM by  anon
about using function curvefit
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
13 Mar 2006 02:06 PM
    I'm a user of IDL for just two weeks. I want to use function curvefit,but find something hard to understand. for example: PRO gfunct, X, A, F, pder bx = EXP(A[1] * X) F = A[0] * bx + A[2] pder = [[bx], [A[0] * X * bx], [replicate(1.0, N_ELEMENTS(X))]] END 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] weights = 1.0/Y A = [10.0,-0.1,2.0] yfit = CURVEFIT(X, Y, weights, A, SIGMA, FUNCTION_NAME='gfunct') PRINT, 'Function parameters: ', A IDL prints: Function parameters: 9.91120 -0.100883 2.07773

    Deleted User



    New Member


    Posts:
    New Member


    --
    13 Mar 2006 02:06 PM
    Think of 'A' as a parameter that is "passed by reference" to use the computer science term. In the case of CURVEFIT, it is appropriate that A have "entry values" when it is passed to the function CURVEFIT. But CURVEFIT has access to 'A's storage address. It modifies the values of 'A' as it processes. When CURVEFIT returns that values of 'A' have the last values that CURVEFIT assigned to 'A's storage location. Here is the explanation of the 'A' parameter in IDL's Online Help for CURVEFIT: "A vector with as many elements as the number of terms in the user-supplied function, containing the initial estimate for each parameter. On return, the vector A contains the fitted model parameters." If you need to retain the values of the original 'A', then you may want to copy them to a second variable, e.g. fittedA = A That would make a copy of the original A data to a new variable called 'fittedA'. Now you can run the statement: yfit = CURVEFIT(X, Y, weights, fittedA, SIGMA, FUNCTION_NAME='gfunct') and CURVEFIT will save its analysis in 'fittedA' rather than in original 'A' James Jones
    You are not authorized to post a reply.