Code covered by the BSD License  

Highlights from
Avantes to Matlab

image thumbnail

Avantes to Matlab

by

 

11 Jun 2012 (Updated )

Read spectral data from Avantes USB2 spectrometer files

getValueAtWavelength(scan, wvl)
function res = getValueAtWavelength(scan, wvl)
% Returns the signal value at the specified wavelength. 
% If the wavelength is beyond the scan range, returns error. 
% Can work with multiple wavelengths and multiple scans. Returns the matrix
% of size (number-of-scans X number-of-wavelengths).
% Uses linear interpolation.

% Copyright (cc-by) K. Karapetyan, kotya.karapetyan@gmail.com, 2011.

res = zeros(numel(scan), numel(wvl));
for i = 1:numel(scan)
    X = [scan(i).wvl];
    if max(wvl) > max(X) || min(wvl) < min(X)
        error('Wavelength beyond the range');
    else
        Y = [scan(i).signal];
        res(i, :) = interp1(X, Y, wvl);
    end
end

Contact us