Main Content

matlab.io.fits.writeHistory

Write HISTORY keyword to current HDU

Syntax

matlab.io.fits.writeHistory(fptr,history)

Description

matlab.io.fits.writeHistory(fptr,history) writes (appends) the history text to a HISTORY keyword in the current HDU. Specify the history argument as a string scalar or character vector. If history is longer than 70 characters, the function writes the text over multiple HISTORY 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 a HISTORY keyword to the current HDU. Then close the file.

fits.writeHistory(fptr,"This is a history keyword.")
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
	HISTORY This is a history keyword.
delete myfile.fits

Tips

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