matlab.io.fits.createTbl
Create new ASCII or binary table extension
Syntax
fptr = createTbl(fptr,tbltype,nrows,ttype,tform,tunit,extname)
Description
fptr = createTbl(fptr,tbltype,nrows,ttype,tform,tunit,extname)
creates a
new ASCII or bintable table extension. tbltype
must be either
'binary'
or 'ascii'
. The nrows
argument gives the initial number of rows to be created in the table and should normally be
zero. tunit
specifies the units for each column, but can be an empty
cell array if no units are desired. extname
specifies the extension
name, but can be omitted.
tform
contains the format of the column, specified as a cell array of
character vectors or a string array. For binary tables, the values should be in the form of
'rt'
, where 'r'
is the repeat count and
't'
is one of the following letters.
'A' | ASCII character |
'B' | Byte or uint8 |
'C' | Complex (single precision) |
'D' | Double precision |
'E' | Single precision |
'I' | int16 |
'J' | int32 |
'K' | int64 |
'L' | Logical |
'M' | Complex (double precision) |
'X' | Bit (int8 zeros and ones) |
A column can also be specified as having variable-width if the tform
value
has the form '1Pt'
or '1Qt'
,
where 't'
specifies the data type as above.
For ASCII tables, tform
contains values that take the form:
'Iw' | int16 column with width 'w' |
'Aw' | ASCII column with width 'w' |
'Fww.dd' | Fixed point |
'Eww.dd' | Single precision with width 'ww' and precision 'dd' |
'Dww.dd' | Double precision with width 'ww' and precision 'dd' |
This function corresponds to the fits_create_tbl(ffcrtb)
function in the
CFITSIO library C API.
Examples
Create a binary table. The first column contains strings of
nine characters each. The second column contains four-element sequences
of bits. The third column contains three-element sequences of uint8
values.
The fourth column contains double-precision scalars.
import matlab.io.* fptr = fits.createFile('myfile.fits'); ttype = {'Col1','Col2','Col3','Col4'}; tform = {'9A','4X','3B','1D'}; tunit = {'m/s','kg','kg/m^3','candela'}; fits.createTbl(fptr,'binary',10,ttype,tform,tunit,'my-table'); fits.closeFile(fptr); fitsdisp('myfile.fits');
Create a two-column table where the first column has a single double-precision value, but the second column has a variable-length double-precision value.
import matlab.io.* fptr = fits.createFile('myfile2.fits'); ttype = {'Col1','Col2'}; tform = {'1D','1PD'}; fits.createTbl(fptr,'binary',0,ttype,tform); fits.closeFile(fptr); fitsdisp('myfile2.fits');
See Also
insertATbl
| insertBTbl
| readCol
| writeCol
| createImg