Main Content

matlab.io.fits.insertBTbl

Insert binary table after current HDU

Syntax

insertBTbl(fptr,nrows,ttype,tform,tunit,extname,pcount)

Description

insertBTbl(fptr,nrows,ttype,tform,tunit,extname,pcount) inserts a new binary table extension immediately following the current HDU. Any following extensions are shifted down to make room for the new extension. If there are no other following extensions then the new table extension is simply appended to the end of the file. If the FITS file is currently empty then this routine creates a dummy primary array before appending the table to it. The new extension becomes the CHDU. If there are following extensions in the file and if the table contains variable-length array columns then pcount must specify the expected final size of the data heap. Otherwise, pcount must be zero.

Specify ttype, tform, and tunits as cell array of character vectors or a string array.

This function corresponds to the fits_insert_btbl (ffibin) function in the CFITSIO library C API.

Examples

Create a table following the primary array. Then, insert a new table just before 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');
fits.movRelHDU(fptr,-1);
fits.insertBTbl(fptr,5,ttype,tform,tunit,'my-new-table',0);
fits.closeFile(fptr);
fitsdisp('myfile.fits');