Operations on all waves inside root
epiphenom
I am trying to perform operations on all waves beginning with "Cell" in root (multiply them by 1000). The code is not throwing any error but it doesn't appear to be working for me. I would appreciate any feedback. This is what I have so far:
Function voltage()
string list
string tracename
variable index =0
SetDataFolder root:
list = WaveList("Cell*", ";", "") //get wavelist matching cell
do
tracename=StringFromList(index,list)
if (strlen(tracename) ==0)
break //ran out of waves
endif
Wave w = $tracename
w *=1000
index+=1
while (index<= strlen(list))
End
<pre><code class="language-igor">
string list
string tracename
variable index =0
SetDataFolder root:
list = WaveList("Cell*", ";", "") //get wavelist matching cell
do
tracename=StringFromList(index,list)
if (strlen(tracename) ==0)
break //ran out of waves
endif
Wave w = $tracename
w *=1000
index+=1
while (index<= strlen(list))
End
<pre><code class="language-igor">
And "doesn't appear to be working" doesn't say much. Do you get run-time errors? Or a bad result? or the waves simply aren't altered?
You may be able to figure out the problem using Igor's symbolic debugger: DisplayHelpTopic "The Debugger"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 17, 2016 at 10:31 am - Permalink
June 17, 2016 at 12:36 pm - Permalink
Your use of strlen is fine. StringFromList returns "" when it runs out of items.
This is wrong:
It should be:
The loop will be terminated by the break statement.
You could write:
but that is not necessary.
BTW, "tracename" is misleading. WaveList returns wave names. TraceNameList returns trace names.
June 17, 2016 at 12:52 pm - Permalink
tracename=StringFromList(index,list)
if (itemsinlist(tracename) ==0)
break //ran out of waves
endif
Wave w = $tracename
w /=1000
index+=1
while (index<= itemsinlist(list))
print list
Cell_10_0489;Cell_10_0487;Cell_10_0488;Cell_10_0490;Cell_10_0491;Cell_10_0492;Cell_10_0493;Cell_10_0494;Cell_10_0495;Cell_10_0496;Cell_10_0497;Cell_10_0498;Cell_10_0499;Cell_10_0500;Cell_10_0501;
Cell_10_0502;Cell_10_0503;Cell_10_0504;Cell_10_0505;Cell_10_0506;Cell_10_0507;Cell_10_0508;Cell_10_0509;Cell_10_0510;Cell_10_0511;Cell_10_0512;Cell_10_0513;Cell_10_0514;Cell_10_0515;Cell_10_0516;
Cell_10_0517;Cell_10_0518;Cell_10_0519;Cell_10_0520;Cell_10_0521;Cell_10_0522;Cell_10_0523;Cell_10_0524;Cell_10_0525;Cell_10_0526;Cell_10_0527;Cell_10_0528;Cell_10_0529;Cell_10_0530;Cell_10_0531;
Cell_10_0532;Cell_10_0533;Cell_10_0534;Cell_10_0535;Cell_10_0536;Cell_10_0537;Cell_10_0538;Cell_10_0539;Cell_10_0540;Cell_10_0541;Cell_10_0542;Cell_10_0543;Cell_10_0544;Cell_10_0545;Cell_10_0546;
Cell_10_0547;Cell_10_0548;Cell_10_0549;Cell_10_0550;Cell_10_0551;Cell_10_0552;Cell_10_0553;Cell_10_0554;Cell_10_0555;Cell_10_0556;Cell_10_0557;Cell_10_0558;Cell_10_0559;Cell_10_0560;Cell_10_0561;
print itemsinlist("list",";")
1
June 17, 2016 at 01:10 pm - Permalink
Remove the quotes around "list".
June 17, 2016 at 01:37 pm - Permalink
June 17, 2016 at 02:39 pm - Permalink