%% Read ECOSTRESS Spectrum Files
% Specify the names of the spectrum files to read from the ECOSTRESS spectral library as a cell array of character vectors. Specify the full file path of each spectrum file.

ecostressfiles = [{'soil.utisol.hapludult.none.all.87p707.jhu.becknic.spectrum.txt'},...
             {'water.seawater.none.liquid.tir.seafoam.jhu.becknic.spectrum.txt'},...
             {'vegetation.tree.eucalyptus.maculata.vswir.jpl087.jpl.asd.spectrum.txt'},...
             {'manmade.road.tar.solid.all.0099uuutar.jhu.becknic.spectrum.txt'}];

% Read and display the data from the specified ECOSTRESS spectrum files. The function returns a structure array with a row for each specified ECOSTRESS spectrum file. Each row stores the spectral data read from the associated file.

libData = readEcostressSig(ecostressfiles)

% Extract the details of the spectral data of the second file from the structure array.

libData(2)

% Extract the reflectance and the wavelength values from the spectral data of the second file.

reflectance = libData(2).Reflectance;
wavelength = libData(2).Wavelength;

% Plot the spectral signature using the wavelength and reflectance values.

figure
plot(wavelength,reflectance)
title(['Spectra of ' libData(2).Name])
xlabel('Wavelength')
ylabel('Reflectance Value')

% Copyright 2020 The MathWorks, Inc.