Contenuto principale

matlab.io.fits.insertRows

Insert rows into table

Syntax

matlab.io.fits.insertRows(fptr,firstrow,nrows)

Description

matlab.io.fits.insertRows(fptr,firstrow,nrows) inserts rows into an ASCII or binary table. The firstrow argument is a one-based number.

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 five new rows at the beginning of the table. Then close the file.

fits.insertRows(fptr,1,5)
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  =                   11 / width of table in bytes
	NAXIS2  =                    5 / number of rows in table
	PCOUNT  =                    0 / size of special data area
	GCOUNT  =                    1 / one data group (required keyword)
	TFIELDS =                    2 / 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
delete myfile.fits

Tips

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