returning several waves from a function
vivishek
As an Igor newbie, I was trying to write a function that does some simple processing of an input wave, which ends up generating two processed waves of the same length and x-scaling. Since I use rtGlobals=3, and prefer to keep using it, there is the problem of somehow returning these 2 waves to the outside world. What is the advised way to do this in Igor? Package them into a matrix of waves? Or is there something else?
And since we are at it, how does one use optional arguments to functions?
Thanks.
Wave/WAVE ww // Output waves returned here
Make/O jack = sin(x/8)
ww[0] = jack // Return to caller
Make/O fred = cos(x/8)
ww[1] = fred // Return to caller
End
Function Test()
Make/FREE/N=2/WAVE theWaves
Subroutine(theWaves)
Wave first = theWaves[0]
Wave second = theWaves[1]
Display first, second
End
You could also use a structure:
Wave first
Wave second
EndStructure
Function Subroutine2(s)
STRUCT Structure2 &s // Output waves returned here
Make/O jack = sin(x/8)
Wave s.first = jack // Return to caller
Make/O fred = cos(x/8)
Wave s.second = fred // Return to caller
End
Function Test2()
STRUCT Structure2 theWaves
Subroutine2(theWaves)
Wave first = theWaves.first
Wave second = theWaves.second
Display first, second
End
Execute this for details:
November 16, 2014 at 10:25 am - Permalink
November 16, 2014 at 12:12 pm - Permalink