Main Content

matlab.io.fits.writeComment

Write COMMENT keyword to current HDU

Syntax

matlab.io.fits.writeComment(fptr,comment)

Description

matlab.io.fits.writeComment(fptr,comment) writes (appends) the comment text to a COMMENT keyword in the current HDU. Specify the comment argument as a string scalar or character vector. If comment is longer than 70 characters, the function writes the text over multiple COMMENT keywords.

Examples

collapse all

Create a new FITS file and add an image to it.

import matlab.io.*
fptr = fits.createFile("myfile.fits");
fits.createImg(fptr,"byte_img",[100 200])

Write two comments to the current HDU. Then close the file.

fits.writeComment(fptr,"This is a comment.")
fits.writeComment(fptr,"This is another comment.")
fits.closeFile(fptr)

Examine the file metadata and then delete the file.

fitsdisp("myfile.fits",Mode="full")
HDU:  1 (Primary HDU)
	SIMPLE  =                    T / file does conform to FITS standard
	BITPIX  =                    8 / number of bits per data pixel
	NAXIS   =                    2 / number of data axes
	NAXIS1  =                  200 / length of data axis 1
	NAXIS2  =                  100 / length of data axis 2
	EXTEND  =                    T / FITS dataset may contain extensions
	COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
	COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
	COMMENT This is a comment.
	COMMENT This is another comment.
delete myfile.fits

Tips

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