Main Content

matlab.io.fits.writeKeyUnit

Write physical units string

Syntax

matlab.io.fits.writeKeyUnit(fptr,keyname,unit)

Description

matlab.io.fits.writeKeyUnit(fptr,keyname,unit) writes the physical units to the specified keyword. Specify the keyname and unit arguments as string scalars or character vectors.

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,"long_img",[10 20])

Write the VELOCITY keyword to the current HDU, and set the keyword's units to kilometers per second. Then close the file.

fits.writeKey(fptr,"VELOCITY",12.3,"orbital speed")
fits.writeKeyUnit(fptr,"VELOCITY","km/s")
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  =                   32 / number of bits per data pixel
	NAXIS   =                    2 / number of data axes
	NAXIS1  =                   20 / length of data axis 1
	NAXIS2  =                   10 / 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
	VELOCITY=                 12.3 / [km/s] orbital speed
delete myfile.fits

Tips

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