X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03 Aug 2020 12:06 PM by  Ben Castellani
Help understanding portion of a script
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

John Hageter



New Member


Posts:
New Member


--
24 Jun 2020 05:11 AM
    I'm not the best with IDL but I have found my way around it. One thing I keep coming across while looking at a portion of an old script is "arr" before each array, but I don't understand where the input is coming from;

    function impact, arr, r

    fl=(findgen(100)+1.)/100.
    parr=arr[*,0]
    for i=1,n_elements(arr[0,*])-1 do begin
    nx=arr[0,(i-1)]+(arr[0,i]-arr[0,(i-1)])*fl
    ny=arr[1,(i-1)]+(arr[1,i]-arr[1,(i-1)])*fl
    parr=[[parr],[transpose([[nx],[ny]])]]
    endfor

    I'm just getting confused as to why arr is before each array and what each array could be referring to. If anyone could give me a bit of help I would really appreciate it. Thank you!

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    03 Aug 2020 12:06 PM
    In your example, "arr" is a generic input parameter to the function called "impact".

    Here an example with a over-simplified mean function:

    function simpleMean, arr
    return, (total(arr)/n_elements(arr))
    end

    To call this function, you provide the "arr" input, like:

    IDL> simpleMean([1,2,3])
    IDL> 2.00000
    You are not authorized to post a reply.