Code covered by the BSD License  

Highlights from
Avantes to Matlab

image thumbnail

Avantes to Matlab



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,, 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');
        Y = [scan(i).signal];
        res(i, :) = interp1(X, Y, wvl);

Contact us