Maximum intensity from graph

Dear Users,

I am trying to extract the maximum intensity between the two points [p] (xmin, xmax) from the graph that has an entire series of data. I have multiple peaks and each peaks has different intensity depending on the experimental variable. I want to plot the the max intensity vs the experimental parameter I am varying. For this I wrote a script (that will print the maximum intensity and the tracename), however I am getting wrong value (the first value of each spectra).

Here is the code:

Function Ymax(graphNamestr, xmin, xmax)
String graphNamestr
Variable xmin, xmax

String list=Tracenamelist(graphnamestr,";",1)
Variable i, numtraces=itemsinlist(list)
make/o/n=(numtraces) int_max
make/o/T/n=(numtraces) tracenames
for(i=0;i<numtraces;i+=1)
String trace=stringfromlist(i,list)
Wave wav=TraceNameToWaveRef(graphnamestr,trace)
int_max[i] = wavemax(wav,xmin,xmax)
tracenames[i]=trace
endfor
Edit int_max tracenames
end

I am also attaching the data set that I am using where xwave1 is the xaxis and rest all is the data. 

Any help is much appreciated.

Thank you,

regards,

Rubin.

Data set that I am using for the above code. xwave1 is the xaxis value and others are the experimental values. (9.45 MB)

My guess is that xmin and xmax are not specified correctly. From your description, the experimental values are plotted against xwave1 but your code is operating on the experimental values without any information from xwave1, i.e. the experimental values have no scaling. So when you input xmin and xmax, if you use x values from xwave1 rather than point numbers they're out of range (or something) which is returning an unexpected value.

The code looks OK. Have you tried specifying some point numbers and see if you get the expected result?

In reply to by sjr51

I wrote the code so that I use the point number rather than the xwave value. I am getting the point number from graph info and it gives the unexpected values. 

Is there a way to also include the xwave information in the code I could not figure that out, maybe that might solve the issue.

thank you for your help.

Hi,

I just tried your code with your sample set.

Created graph with all traces against last wave which appeared to be x values.

Ran your function and then compared with command line of wavemax(wavename, 30,40).

Your function appears to work as intended.

Andy

WaveMax Experiment.pxp (9.29 MB)

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More