
How to access and save individual wave from TraceNameToWaveRef("", traceName)

supra
Usually I drag one of the trace (trace 2 ) to the other and use the code of by "Rgerkin" and then I have two trace in a single graph.
Now when I use "tracename" and use TraceNameToWaveRef("", traceName) and generate y wave and x wave (yw and xw).
Since it is in a loop it access the traces trace1 and trace 2 sequentially and thereby the last yw and xw is always from trace 2.
How I can save the trace 1 in an another variable or use a array function to save the trace1 : xw and yw (say yw1 and xw1) and then can save the trace from the 2nd trace : xw2 and yw2 and then I can do the required subtraction yw=yw2-yw1.
Although in my case the x a values are same (although x waves names are different)..but in case I have a situation whether the x values are different ( point by point ) .., just curious to know ..is it possible to plot yw or I have to interpolate or have to choose either xw1 or xw2 to plot yw ?
String list = TraceNameList("", ";", 1) String traceName Variable index = 0 do traceName = StringFromList(index, list) if (strlen(traceName) == 0) break // No more traces. endif wave yw = TraceNameToWaveRef("", traceName) wave xw = XWaveRefFromTrace("", traceName) ------------------ ?? need to save in a array yw1 and yw2 --------------- index += 1 while(1) end // Want to do the subtraction yw=yw2-yw1
If you *really* want a loop, you will need to make a wave wave (look up the Make command and read about Make/WAVE). In the loop, fill in the wave wave with references to the waves you want.
By the way, the second igor tag needed to be slash-igor to close the code segment.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 18, 2012 at 09:18 am - Permalink
Yes I corrected the tag..thanks
June 18, 2012 at 01:03 pm - Permalink
Next, choose one wave as the basis for your for loop (assuming they have different intervals). For example, I am going to choose xw1. For each value of xw1 in this range (10-40 for the above example numbers), you will need to use interp on yw2. If you always have the case where the intervals of xw1 and xw2 are scalar multiples of eachother, you can avoid using interp but always having the result wave have the same interval spacing as the wave with the fewest datapoints (lowest resolution) and just ignoring the extra data points in the other wave.
where i is the current iteration in your for loop covering the range from 10-40 (again for my example numbers).
I'm vaguely aware of a notation involving the ? symbol that applies a math operation to only a section of a wave, but I'm not sure if that can be used in here place of a for loop (considering interp is required).
June 18, 2012 at 01:56 pm - Permalink
June 20, 2012 at 03:36 pm - Permalink
I wanted to show on a panel the name of the wave subtracted : i,e
with what control I can show it, ValueDispaly is only for numeric value not for string, I tried listbox ...also didnt work.
June 20, 2012 at 04:10 pm - Permalink
June 21, 2012 at 06:37 am - Permalink
June 21, 2012 at 08:11 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 21, 2012 at 10:01 am - Permalink
The code beneath (part of my bigger program) does the subtraction and works on Graph with two trace...Mainly what I want to do is to have option in subtraction (arithmetic) so that using setvar0 and setvar1 control I can define MyNewWave…for example say MyNewWave=
2(wave0)- wave1
wheresetvar1=wave0
andsetvar1=wave1
which I say typed in the servar box. Now in present condition it is always hardcoded aswave2-wave1
orwave1-wave2
(if checkbox 1 is checked) .If tried to declare setvar as string ...and tried to access setvar value as MyNewWave ( say MyNewWave=2(setvar0)-setvar1..where I say handtyped
How can I have this...Pl find atta..the ipf file and one Graph containing two trace
June 23, 2012 at 08:10 pm - Permalink
I then copied the procedures that you posted thinking perhaps they contained the SubtractTracesButton procedure, but no, they don't.
It would be much easier if you would provide a self-contained experiment including all necessary procedures. You can do this by either pasting the procedures in the built-in procedure window or adopting (File->Adopt Procedure) a standalone procedure file. To learn about adopting, execute:
DisplayHelpFile "Adopting a Procedure File"
I now see that the panel in the SumRay.pxp file is obsolete as it has only one SetVariable. If I run, Panel10 I get a new panel with two SetVariables. But still no SubtractTracesButton procedure.
I also note that your Panel10 macro is missing the End statement.
Finally, here is an implementation of the SubtractTracesButton function:
This would be better named as SubtractWaves because it does not have anything to do with graphs or traces in graphs. But perhaps that is something you intend to implement later.
June 23, 2012 at 07:46 pm - Permalink
June 23, 2012 at 09:32 pm - Permalink
1) How can I "parse" the string typed in a setvar input box ...such that if I type 2*wave0 in setvar0 field...then after parsing it should set S_Value = wave0 i,e the true wavename ..not 2*wave0..while "2" will be set as coeff so that in next stage of subtraction it can do
coeff* wave0-wave1..... is there any builtin parsar in Igor.
2) I want to populate the setvar0 and setvar1 field by the "wave name" that exist in a current trace ( as then I dont have to type...) ..I tried to use
but it does work..
June 23, 2012 at 09:31 pm - Permalink
In regards to setting the value of the setvariable, you do not use ControlInfo.
Instead, use
To update a control, use the same commands you used to make it. Note that you only need to include those which you wish to change (I didn't change the position or size above).
June 25, 2012 at 06:08 am - Permalink
indeed your solution
works for me very well..now I can list the waves ..
Thank you so much.
July 10, 2012 at 06:51 pm - Permalink