Contenu principal

matlab.io.fits.insertCol

Insert column into table

Syntax

matlab.io.fits.insertCol(fptr,colnum,ttype,tform)

Description

matlab.io.fits.insertCol(fptr,colnum,ttype,tform) inserts a column into an ASCII or binary table. Specify ttype and tform as string scalars or character vectors.

Examples

collapse all

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

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

Insert a new column into the table. Then close the file.

fits.insertCol(fptr,3,"Col3","3D")
fits.closeFile(fptr)

Examine the file metadata and then delete the file.

fitsdisp("myfile.fits",Index=2)
HDU:  2 
	XTENSION= 'BINTABLE'           / binary table extension
	BITPIX  =                    8 / 8-bit bytes
	NAXIS   =                    2 / 2-dimensional binary table
	NAXIS1  =                   35 / width of table in bytes
	NAXIS2  =                    0 / number of rows in table
	PCOUNT  =                    0 / size of special data area
	GCOUNT  =                    1 / one data group (required keyword)
	TFIELDS =                    3 / number of fields in each row
	TTYPE1  = 'Col1    '           / label for field   1
	TFORM1  = '3A      '           / data format of field: ASCII Character
	TUNIT1  = 'm/s     '           / physical unit of field
	TTYPE2  = 'Col2    '           / label for field   2
	TFORM2  = '1D      '           / data format of field: 8-byte DOUBLE
	TUNIT2  = 'candela '           / physical unit of field
	EXTNAME = 'my-table'           / name of this binary table extension
	TTYPE3  = 'Col3    '           / label for field
	TFORM3  = '3D      '           / format of field
delete myfile.fits

Tips

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