Main Content

matlab.io.fits.readKeyLongStr

Read key as long string value

Syntax

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

Description

[value,comment] = matlab.io.fits.readKeyLongStr(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 and does not truncate value.

Examples

collapse all

Create a new FITS file and add an image and a keyword whose value has 100 characters to it.

import matlab.io.*
fptr = fits.createFile("myfile.fits");
idata = repmat(char(97:106),1,10);
fits.createImg(fptr,"byte_img",[100 200])
fits.writeKey(fptr,"mykey",idata)

Read the key value using the matlab.io.fits.readKey function. The function truncates the value to 68 characters.

[value,~] = fits.readKey(fptr,"mykey")
value = 
'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefg&'

Read the key value again using the matlab.io.fits.readKeyLongStr function. The function does not truncate the value. Then delete the file.

[value,~] = fits.readKeyLongStr(fptr,"mykey")
value = 
'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij'
fits.closeFile(fptr)
delete myfile.fits

Tips

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