Text waves in Igor Pro
A text wave holds strings, and most numeric operations do not apply to it.
Function/WAVE LabelWaves(WAVE values, Variable cut)
Make/O/T/N=(numpnts(values)) labels
WAVE/T labels
labels = SelectString(values[p] > cut, "low", "high")
labels[0] = "reference"
Variable high = 0
high = sum(values, 0, inf) > cut ? 1 : 0
String overall = SelectString(high, "low", "high")
Printf "first label %s, overall %s\r", labels[0], overall
return labels
End
How it works
Make/Tmakes one;WAVE/Tis the reference type.- Assignment works the same way, with
pindexing the points. SelectStringis the string answer to the ternary operator.
Keywords and builtins used here
EndFunctionMakePrintfSelectStringStringVariableWAVEinfnumpntsreturnsum
The run, in numbers
- Lines
- 14
- Characters to type
- 368
- Tokens
- 89
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 71 seconds.
Step 4 of 4 in Text, step 15 of 18 in Language basics.