Open FITS file
fptr = openFile(filename)
fptr = openFile(filename,mode)
fptr = openFile(filename) opens an existing FITS file in read-only mode
and returns a file pointer,
fptr, which references the primary array
(first header data unit, or "HDU"). The
openFile function supports
the extended file name syntax.
This function corresponds to the
fits_open_file (ffopen) function
in the CFITSIO library C API.
openFile function is similar to the function
openDiskFile. In addition to opening FITS files, the
openFile function supports the extended file name syntax in the
input file name. If the filename (or folder path) contains square or curly brace
characters that would confuse the extended filename parser, then use
fptr = openFile(filename,mode) opens an existing FITS file according to
mode, which describes the type of access.
may be either
Open a file in read-only mode and read image data from the primary array.
import matlab.io.* fptr = fits.openFile('tst0012.fits'); imagedata = fits.readImg(fptr); fits.closeFile(fptr);
Open a file in read/write mode and add a comment to the primary array.
import matlab.io.* srcFile = fullfile(matlabroot,'toolbox','matlab','demos','tst0012.fits'); copyfile(srcFile,'myfile.fits'); fileattrib('myfile.fits','+w'); fptr = fits.openFile('myfile.fits','readwrite'); fits.writeComment(fptr,'This is just a comment.'); fits.closeFile(fptr);