
write and run a script that loads waves from files and rename them accordingly

LeChat
I have N data files data.igr (in Igor Text Data format) each of which is contained into a folder DATA_MAIN/run1 ... DATA_MAIN/runN.
What I actually do is that I copy-paste over and over the following script into my command window:
//initialisation (just run once)
•numrun=-1
•string strangle
//LOAD DATA MANUALLY ?
// to be copy-paste several times into the command line
•numrun+=1
•strangle=num2str(angle[numrun])
•strnom="_theta"+strangle
•strname="sz"+strnom
•duplicate/O sz $strname
•strname="sv"+strnom
•duplicate/O svx $strname
•FuncFit/X=1/H="001"/NTHR=0/TBOX=1023 MyFun W_coef svx/X=sz /D /F={0.950000, 4} // (I don't know how to use strings here, as there is the H="001" argument in this command)
•AA[numrun]=W_coef[0]
•BB[numrun]=W_coef[1]
•CC[numrun]=W_coef[2]
Do you know if there is another better way to do so?
In particular, how can I make a loop on loading the files? Also, is it possible to write and run a script? I tried using function, but I don't know how to properly code functions without putting all the waves I am working on, within the function's argument, which is a pain.
Thank you for your help
February 24, 2017 at 07:13 am - Permalink
Also, search IgorExchange code snippets for examples: http://www.igorexchange.com/search/node/LoadWave+type%3Acode_snippet
February 24, 2017 at 09:48 am - Permalink
Also, search IgorExchange code snippets for examples: http://www.igorexchange.com/search/node/LoadWave+type%3Acode_snippet[/q…]
Great, thanks. I think I am getting closer to my goal.
But how to automatically fit using a changing name for the wave to be fit? The fit function argument H="001" with the quotes makes it impossible for me to create and changing string that I
execute
Thank you for your support
February 24, 2017 at 11:22 am - Permalink
Assuming you have for instance a semicolon separated list of waves like the one returned by WaveList you could do something like:
To write an " in a string use \". That means to give a string the value: FuncFit H="001" you need to write String MyString="FuncFit H=\"001\""
February 24, 2017 at 11:42 am - Permalink
Execute this:
and this:
February 24, 2017 at 12:54 pm - Permalink
Thanks! now I've got it ;)
Here is my code:
February 27, 2017 at 02:29 am - Permalink
with
You can do the same for the FuncFit line.
I assume you use DoUpdate and Sleep to turn the updates into an animation of sorts?
February 28, 2017 at 05:25 am - Permalink