Main Content

matlab.io.fits.readCol

Read rows of ASCII or binary table column

Syntax

[coldata,nullval] = matlab.io.fits.readCol(fptr,colnum)
[coldata,nullval] = matlab.io.fits.readCol(fptr,colnum,firstrow,numrows)

Description

[coldata,nullval] = matlab.io.fits.readCol(fptr,colnum) reads an entire column from an ASCII or binary table column. The nullval output argument is a logical array specifying whether the corresponding element of coldata is undefined. The nullval and coldata arguments are the same size.

[coldata,nullval] = matlab.io.fits.readCol(fptr,colnum,firstrow,numrows) reads a subsection of rows from an ASCII or binary table column.

The MATLAB® data type returned by this function corresponds to the data type returned by the matlab.io.fits.getEqColType function.

Examples

collapse all

Read the entire flux column from a table in a sample FITS file. Then close the file.

import matlab.io.*
fptr = fits.openFile("tst0012.fits");
fits.movAbsHDU(fptr,2);
[colnum,~] = fits.getColName(fptr,"flux");
fluxdata = fits.readCol(fptr,colnum)
fluxdata = 11×3 single matrix

    1.0000    2.0000    3.0000
    1.0000         0    3.0000
   -0.0000    2.0000    3.0000
    1.0000    2.0000    2.0000
    1.0000    2.0000         0
    0.0000    2.0000    3.0000
    1.0000 -484.4618    3.0000
   -4.0000    2.0000    3.0000
    1.0000    2.0000         0
    1.0000    2.0000    3.0000
    1.0000   -0.0000    3.0000
      ⋮

fits.closeFile(fptr)

Read the first five rows of the flux column from a table in a sample FITS file. Then close the file.

import matlab.io.*
fptr = fits.openFile("tst0012.fits");
fits.movAbsHDU(fptr,2);
[colnum,~] = fits.getColName(fptr,"flux");
fluxdata = fits.readCol(fptr,colnum,1,5)
fluxdata = 5×3 single matrix

    1.0000    2.0000    3.0000
    1.0000         0    3.0000
   -0.0000    2.0000    3.0000
    1.0000    2.0000    2.0000
    1.0000    2.0000         0

fits.closeFile(fptr)

Tips

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