Main Content

matlab.io.fits.insertBTbl

Insert binary table after current HDU

Syntax

matlab.io.fits.insertBTbl(fptr,nrows,ttype,tform,tunit,extname,pcount)

Description

matlab.io.fits.insertBTbl(fptr,nrows,ttype,tform,tunit,extname,pcount) inserts a new binary table extension immediately following the current HDU. Any subsequent extensions are shifted down to make room for the new extension. If the FITS file is currently empty, then this function creates an empty primary array before appending the table extension to the file. The new extension becomes the current HDU. If the file has subsequent extensions and the table contains variable-length array columns, then you must specify pcount as the expected final size of the data heap; otherwise, specify pcount as zero.

Specify the ttype, tform, and tunits arguments as string arrays or cell arrays of character vectors.

Examples

collapse all

Create a new FITS file and add a binary table to it.

import matlab.io.*
fptr = fits.createFile("myfile.fits");
ttype = ["Col1","Col2"];
tform = ["9A","1D"];
tunit = ["m/s","candela"];
fits.createTbl(fptr,"binary",10,ttype,tform,tunit,"my-table");

Move the current HDU header back by one, insert a second binary table, and then close the file.

fits.movRelHDU(fptr,-1);
fits.insertBTbl(fptr,5,ttype,tform,tunit,"my-new-table",0)
fits.closeFile(fptr)

Examine the file metadata and then delete the file.

fitsdisp("myfile.fits",Mode="min")
HDU 1:  SHORT_IMG IMAGE_HDU [  ]
HDU 2:  BINARY_TBL [ 5 2 ]
HDU 3:  BINARY_TBL [ 10 2 ]
delete myfile.fits

Tips

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