Conditional assignment in text wave
kpantzas
I'd like to create a "labels" text wave to use in my experiment. Manually, I'd enter the contents of the
labels
wave like this:labels[0] = "img01_H"
labels[1] = "img01_V"
labels[2] = "img02_H"
labels[3] = "img02_V"
labels[1] = "img01_V"
labels[2] = "img02_H"
labels[3] = "img02_V"
I though I could speed things up using conditional assignments, as shown below:
Make/T/N=20 labels
labels = (mod(p,2)==0)? "img0"+num2str(floor(p/2)+1)+"H" : "img0"+num2str(floor(p/2)+1)+"V"
labels = (mod(p,2)==0)? "img0"+num2str(floor(p/2)+1)+"H" : "img0"+num2str(floor(p/2)+1)+"V"
But this throws back the syntax error:
got "mod" instead of string variable or string function name
I guess conditional wave assignments do not work in Igor Pro 6.38?
<expression> ? <TRUE> : <FALSE>
When expression is nonzero, it evaluates the TRUE part, otherwise it evaluates the FALSE part.
The ":" character in the conditional operator must always be separated with spaces from the two adjacent operands.
The operands must be numeric; for strings, you must use the SelectString function.
October 25, 2016 at 09:02 am - Permalink
The argument in the conditional statement is
mod(p,2)
. It is a numeric argument operating on the wavep
index. I guess you mean all operands must be strings in the conditional assignment?In any case,
SelectString
does the trick:Thank you!
October 26, 2016 at 01:45 am - Permalink
All the arguments for the conditional operator must be numeric. The conditional, the true part and the false part must all be numeric. So the only way to achieve what you want is via SelectString.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
October 27, 2016 at 10:43 am - Permalink