Matlab read FITS image stacks

Related: read FITS image stack in Python

In Matlab, it is possible to read specific frame(s) from a FITS file. That is, you can read frames one at a time from a large multi-frame FITS file in MATLAB. This avoids overwhelming RAM or taking an excessive time to load just one or a few image frames from a FITS file.


Reads each frame of a 4096-frame FITS file, with each frame being 256x256 pixels.

for i = 1:4096
  currFrame = fitsread('myFile.fits','PixelRegion',{[1 256],[1 256],i);


GNU Octave FITS reading is done with the fits package with different syntax.