
Wave Arithmetic with String reference waves($)

gdquiceno
Hello,
I am new to igor pro and trying to code a loop where I can create a batch of new waves from the difference of 2 waves. The target waves are based on the cursors on another graph. I tried using MatrixOP and used string list as a wave reference for the new wave names and a string list wave reference for one of the waves in the matrix expression. In my code, MatrixOP doesnt recognize the string list as the reference wave and therefore get an error message. Could any please offer any suggestions?
Many thanks
static function VoltammogramsMatrix2() //make baseline wave string theWaveList=WaveList("Cal*", ";", "DIMS:1") string theWaveNamebase string baseLineList= "" variable q=0 variable a=pcsr(A, "Timec") variable b=pcsr(B, "Timec") for(q=a; q<b+1; q+=1) theWaveNamebase=StringFromList(q, theWaveList) baseLineList=AddListItem(theWaveNamebase, baseLineList, ";") endfor fWaveAverage(baseLineList, "", 0,0, "baseline", "") //make the stimulus waves list variable firstw=pcsr(C, "Timec") variable lastw=pcsr(D, "Timec") variable w=0 string stimWaveList= "" for(w=firstw; w<lastw+1; w+=1) theWaveNameBase=StringFromList(w, theWaveList) stimWaveList=AddListItem(theWaveNamebase, stimWaveList, ";") wave stim=$stimWaveList print stimWaveList endfor //make the diff name list string diffList= "" for(w=firstw; w<lastw+1; w+=1) string name=StringFromList(w, theWaveList)+"_diff" diffList=AddListItem(name, diffList, ";") wave diff=$diffLIst print diffList endfor //make diff waves variable num=(ItemsInList(diffList, ";") print num for(w=0; w<(num+1); w+=1) wave diff=$StringFromList(w, diffList) wave stim=$StringFromList(w, stimWaveList) wave base=baseline MatrixOP /O /S diff=stim-base endfor end

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
May 8, 2019 at 07:40 am - Permalink
I'm not sure what this refers to:
wave base=baseline
Execute this for information about wave references:
DisplayHelpTopic "Wave References"
Execute this for information about debugging wave references:
If you can create a minimal, self-contained example that anyone can execute, you will likely get a quick and accurate answer.
May 8, 2019 at 01:51 pm - Permalink
In reply to I'm not sure what this… by hrodstein
@hrodstein thanks for the suggestions on the display topics. Had previously looked at wave references one but will look at it again to see if it will shed some light on my problem. In the meantime Ive compiled a minimal self contained example for others to help if they can:
This code follows the same principle as the previously posted code for my data analysis. I hope this helps and everyone feel free to provide input. Thanks!
May 10, 2019 at 05:54 am - Permalink
I think the following code does what you want:
Igor was giving an error on this statement:
wave diff=$StringFromList(i, diffList)
At the time the code executes, there is no wave whose name is the result of evaluating the expression on the right hand side (eg. no stim#_diff wave. Instead, you need to use the $ operator in the MatrixOp expression to provide a name for the output wave.
May 10, 2019 at 07:45 am - Permalink
In reply to I think the following code… by aclight
@aclight, sorry for the very late message but thanks so much for your suggestion, it worked for me!
May 27, 2019 at 07:27 am - Permalink