really basic iteration
| pjfd | August 20, 2010 - 07:21 | ||
|---|---|---|---|
|
Hi everyone, 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 i want to do something like variable n = 0 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. have a nice weekend P |
|||

Joined: 2007-08-14
Location: United States
Once you do this, on the command line, you can try ...
HTH
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
Joined: 2010-08-20
Location: Spain
great!
many txs, i'll try it over during the we
cheers
Joined: 2007-09-19
Location: Germany
This line should be:
nt = itemsinlist(theList)(I actually don't know, why the compiler throws no error.)
Joined: 2007-08-14
Location: United States
This line should be:
nt = itemsinlist(theList)Fixed. Thank you.
I wrote it here, not in Igor.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
Joined: 2007-09-19
Location: Germany
I wrote it here, not in Igor.
But I pasted it into the procedure window and it compiled without error, although
numpntsis supposed to work on waves (and not on strings).Joined: 2010-08-20
Location: Spain
Hi guys,
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
Joined: 2007-09-19
Location: Germany
I prepended the 'DIF_' suffix, because otherwise you will end up with something like wave0_DIF_DIF if you call the function twice.
A.
Joined: 2010-08-20
Location: Spain
thanks. that has all been useful and works fine.
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
Joined: 2007-09-19
Location: Germany
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
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
Joined: 2007-08-14
Location: United States
wave0 vs wave1, wave 2 vs wave3, wave4 vs wave 5, ... and so on.
It can be done, but it strongly depends on how your wave are named.
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
Joined: 2007-08-14
Location: United States
wave0 vs wave1, wave 2 vs wave3, wave4 vs wave 5, ... and so on.
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
Joined: 2009-11-01
Location: Canada
pjfd, since you find yourself doing these sort of tasks often, you might want to create wave references inside a loop, like:
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.