简体   繁体   中英

Excluding saturated spectra above a determined threshold in a graph using MATLAB

I have a code that reads my data file and give me some spectra in a graph. Some of these spectra are saturated and I need to exclude them out of my graph. I am unable to attaché the picture that shows the graph and the saturated spectra area in the graph as I am new to the website.

This is the command that plots this picture:

plot(spectra.wavelength(spectrometer.pixel_range)*1e9,
spectra.smooth_counts(spectrometer.pixel_range,:));

I need to determine a threshold on the Y axis (ex: 90% of the whole Y scale [0.9]) and write a command that will exclude the spectra above the threshold (the saturated spectra).

I would really appreciate any kind of help or guidance over this difficulty I am facing as I spent a lot of time trying to fix this issue. It is a matter of one command I believe and I not quite well in MATLAB.

Thank you in advance

Check out the prctile function. If I'm reading this correctly, spectra.wavelength(spectrometer.pixel_range) is just a 1D array of values, so you use prctile to find a treshold, and then create a new 1D array that are equal to or below that threshold.

y1 = spectra.wavelength(spectrometer.pixel_range)
thres = prctile(y1,[90],1);
y_adjusted = y1((y1(:) <= thres(:)));

and then you would plot from there. Of course this would need some adjusting if spectra.wavelength(spectrometer.pixel_range) isn't just a 1D array, so you might want to further describe that variable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM