Open FITS file
fptr = openDiskFile(
opens an
existing FITS file in read-only mode and returns a file pointer
filename
)fptr
, which is the first header data unit (HDU).. The
openDiskFile
function does not support the extended-file-name
syntax.
This function corresponds to the fits_open_diskfile (ffdkopen)
function in the CFITSIO library C API.
The openDiskFile
function is similar to the openFile
function, except that openDiskFile
does
not support the extended-file-name syntax in the input file name. Use
openDiskFile
in cases where the file name (or folder path)
contains square or curly brace characters that would confuse the extended-file-name
parser.
Open a FITS file to read image data, create a copy of the file, and then write a comment to the primary array.
Open a file in read-only mode and read image data from the primary array.
import matlab.io.* fptr = fits.openDiskFile('tst0012.fits'); imagedata = fits.readImg(fptr); % read image from primary array fits.closeFile(fptr);
Create a new file in read/write mode, copy data into the file, and then add a comment to the primary array.
srcFile = fullfile(matlabroot,'toolbox',... 'matlab','demos','tst0012.fits'); copyfile(srcFile,'myfile.fits'); fileattrib('myfile.fits','+w'); fptr = fits.openDiskFile('myfile.fits','readwrite'); fits.writeComment(fptr,'This is just a comment.'); fits.closeFile(fptr);