%% Read Subsample of FITS File
% Read a subsample of data from a FITS file.
% First, get information about the FITS file.

info = fitsinfo('tst0012.fits')

% Query the sizes of each dimension of the image extension.

info.Image.Size

% Store the row and column sizes.

rowend = info.Image.Size(1);
colend = info.Image.Size(2);

% Read every other row and column from the fifth element of the third dimension of the FITS file.

 primaryData = fitsread('tst0012.fits','image', ...
              'Info', info,...
              'PixelRegion',{[1 2 rowend], [1 2 colend], 5 });

% Copyright 2020 The MathWorks, Inc.