Contenuto principale

matlab.io.fits.readKeyUnit

Read physical units string from keyword

Syntax

units = matlab.io.fits.readKeyUnit(fptr,keyname)

Description

units = matlab.io.fits.readKeyUnit(fptr,keyname) returns the physical units from the specified keyword. Specify the keyname argument as a string scalar or character vector. The function returns units as a character vector. If no units are defined, the function returns units as an empty character vector.

Examples

collapse all

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

import matlab.io.*
fptr = fits.createFile("myfile.fits");
fits.createImg(fptr,"long_img",[10 20])
fits.writeKey(fptr,"VELOCITY",12.3,"orbital speed")
fits.writeKeyUnit(fptr,"VELOCITY","km/s")

Read the units for the key value and then delete the file.

units = fits.readKeyUnit(fptr,"VELOCITY")
units = 
'km/s'
fits.closeFile(fptr)
delete myfile.fits

Tips

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