
really basic iteration

pjfd
here is the thing. i want to write a simple macro that, let's say, differentiate waves that have the same root name. i e. wave0, wave1, wave 2, etc. so, instead of going
differentiate wave0
differentitate wave1
differentiate wave2
...etc
i want to do something like
variable n = 0
differentiate wave(n)
n+=1
etc
but i have have a problem with the basic syntax, and i am not able to find the right way to do it in the monstuous manual.
so, i woul really appreciate some feedback on this simple matter.
thanks in advance.
have a nice weekend
P
Once you do this, on the command line, you can try ...
HTH
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
August 21, 2010 at 06:55 am - Permalink
many txs, i'll try it over during the we
cheers
August 20, 2010 at 09:10 am - Permalink
This line should be:
nt = itemsinlist(theList)
(I actually don't know, why the compiler throws no error.)
August 20, 2010 at 02:02 pm - Permalink
Fixed. Thank you.
I wrote it here, not in Igor.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
August 21, 2010 at 06:56 am - Permalink
But I pasted it into the procedure window and it compiled without error, although
numpnts
is supposed to work on waves (and not on strings).August 21, 2010 at 07:50 am - Permalink
I tried the function and it works just fine. Many thanks.
I have a small problem though. I need to preserve the original waves, meaning each derivative should be stored in a different wave. Now, if I try to duplicate the source waves before differentiation or store the derivative in a new wave I encounter again the same problem, meaning having to rename output waves in numerical order, such as wave0_DIF, wave1_DIF, wave3_DIF. Could you please give a suggestion to solve this little problem?
Thanks
P
August 23, 2010 at 04:20 am - Permalink
I prepended the 'DIF_' suffix, because otherwise you will end up with something like wave0_DIF_DIF if you call the function twice.
A.
August 23, 2010 at 12:38 pm - Permalink
final point: i would like to plot in one graph multiple waves, such as
wave0 vs wave1, wave 2 vs wave3, wave4 vs wave 5, ... and so on. is there a simple way to do it with a function? i have more than a thousand pairs, so i cannot go doing it by hand
P
August 26, 2010 at 12:42 am - Permalink
It can be done, but it strongly depends on how your wave are named.
Steps that may be involved are:
create a stringlist for the y waves and the x waves (see wavelist, sortlist, etc.)
iterate trough the lists and convert each item into an wave reference (see stringfromlist, wave, for-endfor, etc.)
and append them to the graph (see appendtograph)
Andreas
August 26, 2010 at 01:17 am - Permalink
With the short list above using only ten waves where they are plotted as odd versus even, you would be able to generate the x-wave and y-wave lists using a GrepList command of the type ...
Extending this code to work for sequences of waves beyond ten is left as an exercise for the reader :-)
ANSWER:
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
August 26, 2010 at 06:27 am - Permalink
Presuming your wave names are as quoted here, the recent development release of LinkDisplay will now allow you to do the following at the command line or in a procedure:
The last two lines presume that you want to show all y-waves on one graph. If each y-wave is to be shown on its own graph, do instead ...
The help file for LinkDisplay explains briefly the command syntax.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
August 26, 2010 at 12:35 pm - Permalink
I'm not sure whether this is "recommended" but I find it useful when I don't want to use wave0 wave1 wave2 style names.
August 30, 2010 at 12:13 pm - Permalink