This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Delete current HDU in FITS file


HDU_TYPE = deleteHDU(fptr)


HDU_TYPE = deleteHDU(fptr) deletes the current HDU in the FITS file. Any following HDUs will be shifted forward in the file, filling the gap created by the deleted HDU. In the case of deleting the primary array (the first HDU in the file) then the current primary array will be replaced by a null primary array containing the minimum set of required keywords and no data. If there are more HDUs in the file following the HDU being deleted, then the current HDU will be redefined to point to the following HDU. If there are no following HDUs then the current HDU will be redefined to point to the previous HDU. HDU_TYPE returns the type of the new current HDU.

This function corresponds to the fits_delete_hdu (ffdhdu) function in the CFITSIO library C API.


Delete the second HDU in a FITS file.

srcFile = fullfile(matlabroot,'toolbox','matlab','demos','tst0012.fits');
fptr = fits.openFile('myfile.fits','readwrite');
new_current_hdu = fits.deleteHDU(fptr);

See Also