Main Content

matlab.io.fits.insertImg

Insert FITS image after current HDU

Syntax

matlab.io.fits.insertImg(fptr,bitpix,naxes)

Description

matlab.io.fits.insertImg(fptr,bitpix,naxes) inserts a new image extension immediately following the current HDU. Any subsequent extensions in the file are shifted down to make room for the new extension. If the FITS file is currently empty, then this function inserts the image as the primary array. The new extension becomes the current HDU.

Examples

collapse all

Create a new FITS file and add two images to it.

import matlab.io.*
fptr = fits.createFile("myfile.fits");
fits.createImg(fptr,"byte_img",[100 200])
fits.createImg(fptr,"byte_img",[200 400])

Move the current HDU header back by one so that the insertImg function will insert a new image between the first two images.

fits.movRelHDU(fptr,-1);

Insert a new image. Then close the file.

fits.insertImg(fptr,"byte_img",[150 300])
fits.closeFile(fptr)

Examine the file metadata and then delete the file.

fitsdisp("myfile.fits",Mode="min")
HDU 1:  BYTE_IMG IMAGE_HDU [ 100 200 ]
HDU 2:  BYTE_IMG IMAGE_HDU [ 150 300 ]
HDU 3:  BYTE_IMG IMAGE_HDU [ 200 400 ]
delete myfile.fits

Tips

  • This function corresponds to the fits_insert_imgll (ffiimgll) 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