MATLAB: How to normalize a plot

MATLABnormalizationplot

Hi, can anybody help me to understand how to normalize a spectrum ? I have a spectra and I want to obtain its area equal to 1. Thanks in advance.

Best Answer

If you want the area to be 1.0, create the sum over the spectrum and divide the values by the result.
spectrum = rand(1, 100); % Example data
normalized = spectrum / sum(spectrum);