Main Content

matlab.io.fits.deleteHDU

删除 FITS 文件中当前的 HDU

语法

HDU_TYPE = deleteHDU(fptr)

说明

HDU_TYPE = deleteHDU(fptr) 删除 FITS 文件中当前的 HDU。文件中的所有后续 HDU 都会相应前移,填补已删除的 HDU 产生的空缺。如果删除主数组(文件中的第一个 HDU),那么,当前主数组将被替换为包含最少必需关键字集且无数据的空主数组。如果文件中被删除的 HDU 后面跟有更多 HDU,则当前 HDU 将重新定义为指向下一个 HDU。如果后面未跟 HDU,则当前 HDU 将重新定义为指向上一个 HDU。HDU_TYPE 返回当前新 HDU 的类型。

此函数对应于 CFITSIO 库 C API 中的 fits_delete_hdu (ffdhdu) 函数。

示例

删除 FITS 文件中的第二个 HDU。

import matlab.io.*
srcFile = fullfile(matlabroot,'toolbox','matlab','demos','tst0012.fits');
copyfile(srcFile,'myfile.fits');
fileattrib('myfile.fits','+w');
fitsdisp('myfile.fits','mode','min');
fptr = fits.openFile('myfile.fits','readwrite');
fits.movAbsHDU(fptr,2);
new_current_hdu = fits.deleteHDU(fptr);
fits.closeFile(fptr);
fitsdisp('myfile.fits','mode','min');

另请参阅