MATLAB: Do I receive no data while reading a FITS file using FITSREAD in MATLAB 7.6 (R2008a)

bintablefitsinfoimageMATLABprocessing

I am trying to load a FITS file. However, when I enter
data=fitsread(filename)
I receive an empty array. How do I properly load in the file?

Best Answer

This is an expected behavior when using the FITSREAD command in MATLAB 7.6 (R2008a).
The reason an empty data array is returned is as follows:
The FITS files has two types of data:
1. Primary
2. BinaryTable
When the Primary type has no data in it, FITSREAD with no options returns an empty data array. The syntax: FITSREAD(filename) reads the Primary Type data by default. Hence you do not see any data in it.
However, there could data in the binary table. In order to retrieve the data from the binary table, one needs to use the following additional argument (bintable) while calling FITSREAD.
data=fitsread(filename,'bintable')