%% Remove Bands in Specified Wavelength Range
% Read hyperspectral data into the workspace.

hcube = hypercube('paviaU.dat');

% Inspect the properties of the hypercube object.

hcube

% Find the spectral wavelength range of the hyperspectral data cube.

range = [min(hcube.Wavelength) max(hcube.Wavelength)]

% Specify the ranges of wavelengths to be remove from the hyperspectral data cube.

wlrange = [410 450; 620 850];

% Remove the spectral bands that lie in the specified wavelength ranges. The function returns a new hypercube object without the removed bands.

newhcube = removeBands(hcube,'Wavelength',wlrange)

% Plot the original and the new wavelength values.

figure
plot(hcube.Wavelength,'o')
hold on
plot(newhcube.Wavelength,'or')
xlabel('Band Number')
ylabel('Wavelength')
legend('Original Values','New Values','Location','SouthEast')

% Copyright 2020 The MathWorks, Inc.