Main Content

matlab.io.fits.readKey

Read key value

Syntax

[value,comment] = matlab.io.fits.readKey(fptr,keyname)

Description

[value,comment] = matlab.io.fits.readKey(fptr,keyname) returns the specified key value and comment. Specify the keyname argument as a string scalar or character vector. The function returns value and comment as character vectors.

Examples

collapse all

Read the key values and comments for all instances of the keyword NAXIS in a sample FITS file.

import matlab.io.*
fptr = fits.openFile("tst0012.fits");
N = fits.getNumHDUs(fptr);
for j = 1:N
    fits.movAbsHDU(fptr,j);
    [value,comment] = fits.readKey(fptr,"NAXIS");
    fprintf('HDU %d: NAXIS %s, "%s"\n',j,value,comment)
end
HDU 1: NAXIS 2, "No. of axes in matrix"
HDU 2: NAXIS 2, "Binary tables have 2 axes"
HDU 3: NAXIS 13, "A total of 13 axes !!!"
HDU 4: NAXIS 3, "Three axes"
HDU 5: NAXIS 2, "ASCII tables has 2 axes"
fits.closeFile(fptr)

Tips

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