matlab.io.fits.writeCol

Write elements into ASCII or binary table column

Syntax

writeCol(fptr,colnum,firstrow,coldata)

Description

writeCol(fptr,colnum,firstrow,coldata) writes elements into an ASCII or binary table extension column.

When writing rows of data to a variable length field, coldata must be a cell array.

This function corresponds to the fits_write_col" (ffpcl) function in the CFITSIO library C API.

Examples

Write to a table with ASCII, uint8, double-precision, and variable-length double-precision columns.

import matlab.io.*
fptr = fits.createFile('myfile.fits');
ttype = {'Col1','Col2','Col3','Col4'};
tform = {'3A','3B','1D','1PD'};
tunit = {'m/s','kg/m^3','candela','parsec'};
fits.createTbl(fptr,'binary',0,ttype,tform,tunit,'my-table');
fits.writeCol(fptr,1,1,['dog'; 'cat']);
fits.writeCol(fptr,2,1,[0 1 2; 3 4 5; 6 7 8; 9 10 11]);
fits.writeCol(fptr,3,1,[1; 2; 3; 4]);
fits.writeCol(fptr,4,1,{1;[1 2];[1 2 3];[1 2 3 4]});
fits.closeFile(fptr);
fitsdisp('myfile.fits','index',2,'mode','full');

Write to a table with logical, bit, double precision, and variable-length complex single-precision columns.

import matlab.io.*
fptr = fits.createFile('myfile.fits');
ttype = {'Col1','Col2','Col3','Col4'};
tform = {'2L','3X','1D','1PC'};
tunit = {'','kg/m^3','candela','parsec'};
fits.createTbl(fptr,'binary',0,ttype,tform,tunit,'my-table');
fits.writeCol(fptr,1,1,[false false; true false]);
fits.writeCol(fptr,2,1,int8([0 1 1; 1 1 1; 1 1 1; 1 0 1]));
fits.writeCol(fptr,3,1,[1; 2; 3; 4]);
data = cell(4,1);
data{1} = single(1);
data{2} = single(1+2j);
data{3} = single([1j 2 3+j]);
data{4} = single([1 2+3j 3 4]);
fits.writeCol(fptr,4,1,data);
fits.closeFile(fptr);
fitsdisp('myfile.fits','index',2,'mode','full');

See Also

|

Was this topic helpful?