Open FITS file
fptr = openDiskFile( opens an
existing FITS file in read-only mode and returns a file pointer
fptr, which is the first header data unit (HDU).. The
openDiskFile function does not support the extended-file-name
This function corresponds to the
function in the CFITSIO library C API.
openDiskFile function is similar to the
openFile function, except that
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
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);
filename— Name of file to read
Name of the file to read, specified as a character vector. The
openDiskFile function does not support the extended
file name syntax.
Example: If the
openDiskFile writes the file
'tst0012.fits' to the folder
mode— File access type
File access type, specified as a character vector containing
'readonly' — Open file for reading.
'readwrite' — Open file for reading and