Main Content

matlab.io.fits.copyHDU

Copy current HDU from one file to another

Syntax

matlab.io.fits.copyHDU(infptr,outfptr)

Description

matlab.io.fits.copyHDU(infptr,outfptr) copies the current HDU from the FITS file associated with infptr and appends it to the FITS file associated with outfptr.

Examples

collapse all

Copy the first, third, and fifth HDUs from one file to another.

import matlab.io.*
infptr = fits.openFile("tst0012.fits");
outfptr = fits.createFile("myfile.fits");
fits.copyHDU(infptr,outfptr)
fits.movAbsHDU(infptr,3);
fits.copyHDU(infptr,outfptr)
fits.movAbsHDU(infptr,5);
fits.copyHDU(infptr,outfptr)
fits.closeFile(infptr)
fits.closeFile(outfptr)

Compare the first, third, and fifth HDUs from tst0012.fits to the HDUs from myfile.fits.

fitsdisp("tst0012.fits",Mode="min",Index=[1 3 5])
HDU 1:  FLOAT_IMG IMAGE_HDU [ 109 102 ]
HDU 3:  BYTE_IMG IMAGE_HDU [ 41 17 1 1 1 1 1 1 1 1 1 1 2 ]
HDU 5:  ASCII_TBL [ 53 8 ]
fitsdisp("myfile.fits",Mode="min")
HDU 1:  FLOAT_IMG IMAGE_HDU [ 109 102 ]
HDU 2:  BYTE_IMG IMAGE_HDU [ 41 17 1 1 1 1 1 1 1 1 1 1 2 ]
HDU 3:  ASCII_TBL [ 53 8 ]

Delete the new file myfile.fits.

delete myfile.fits

Tips

  • This function corresponds to the fits_copy_hdu (ffcopy) function in the CFITSIO library C API.

  • To use this function, you must be familiar with the CFITSIO C interface. You can access the CFITSIO documentation at the CFITSIO website.

Extended Capabilities

expand all

Version History

expand all