Unexpected Wave Error: Using WaveStats in a Procedure Function
mschulze
I need help because I have a series of datafiles with a basename ("mws_2-125_00", "mws_2-125_10", "mws_2-125_20"...) that increment (but a zero is placed at the end). My real issue is trying to find the maxima and its index of each datafile all at once and store those the maxima and index in a matrix.
I have written a function, but I keep getting an error I do not understand "Wavestats error: unexpected wavename". The compiler says my function is OK, but when I execute I get the error.
function Peaks(basename)
string basename
Make/O/N=(119,2)/D results
string swave
variable j
for(j=0;j<120;j+=119)
swave = "basename"+num2str(j)+"0"
wave temp = $swave
wavestats temp
results[j] [0] = V_max // maximum in column 1
results[j] [1] = V_maxloc // indexed value in column 2
endfor
end
string basename
Make/O/N=(119,2)/D results
string swave
variable j
for(j=0;j<120;j+=119)
swave = "basename"+num2str(j)+"0"
wave temp = $swave
wavestats temp
results[j] [0] = V_max // maximum in column 1
results[j] [1] = V_maxloc // indexed value in column 2
endfor
end
Please help. Any other method to process a series of a hundred or more datafiles at a time to find and store the maxima and index would be appreciated. I am new to Igor and this has been very time consuming/frustrating.
Thank you so much in advance.
December 21, 2012 at 02:01 pm - Permalink
Waves which start with a number will have to be surrounded with single quotes most times, but certain functions will reject the name with the single quotes so it can be tricky.
December 21, 2012 at 02:21 pm - Permalink
should be this:
I figured this out using the debugger:
The function will work with liberal names (e.g., containing a dash) because this statement works with liberal names without quoting:
To learn about liberal names, execute:
DisplayHelpTopic "Accessing Global Variables and Waves Using Liberal Names"
December 21, 2012 at 03:35 pm - Permalink
Indeed, the problem was the non-standard names. It also took me a really long time to do this, but I was able to rename all my files into simpler names, and the function I wrote then worked right away.
.....I don't know if I want to scream because I am happy it works or because it took so long and yet was so simple!!!
December 21, 2012 at 11:22 pm - Permalink