matlab.io.fits.insertATbl

Insert ASCII table after current HDU

Syntax

insertATbl(fptr,rowlen,nrows,ttype,tbcol,tform,tunit,extname)

Description

insertATbl(fptr,rowlen,nrows,ttype,tbcol,tform,tunit,extname) inserts a new ASCII 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 current HDU. If rowlen is 0, then CFITSIO calculates the default rowlen based on the tbcol and ttype values.

Specify tform as a cell array of character vectors or a string array that can take the following forms. In each case, 'w' and 'ww' represent the widths of the ASCII columns.

'Iw'int16 column
'Aw'ASCII column
'Fww.dd'Fixed point with 'dd' digits after the decimal point
'Eww.dd'Single precision with 'dd' digits of precision
'Dww.dd'Double precision with 'dd' digits of precision

Binary tables are recommended instead of ASCII tables.

This function corresponds to the fits_insert_atbl(ffitab) function in the CFITSIO library C API.

Examples

Create an ASCII table between two images.

import matlab.io.*
fptr = fits.createFile('myfile.fits');
fits.createImg(fptr,'uint8',[20 30]);
fits.createImg(fptr,'int16',[30 40]);
fits.movRelHDU(fptr,-1);
ttype = {'Name','Short','Fix','Double'};
tbcol = [1 17 28 43];
tform = {'A15','I10','F14.2','D12.4'};
tunit = {'','m**2','cm','km/s'};
fits.insertATbl(fptr,0,0,ttype,tbcol,tform,tunit,'my-table');
fits.writeCol(fptr,1,1,char('abracadabra','hocus-pocus'));
fits.writeCol(fptr,2,1,int16([0; 1]));
fits.writeCol(fptr,3,1,[12.4; 4/3]);
fits.writeCol(fptr,4,1,[12.4; 4e8/3]);
fits.closeFile(fptr);
fitsdisp('myfile.fits','mode','min');