Main Content

matlab.io.fits.createFile

Create FITS file

Syntax

fptr = matlab.io.fits.createFile(filename)

Description

fptr = matlab.io.fits.createFile(filename) creates a FITS file. Specify filename as a string scalar or character vector. If the specified file already exists, the function issues an error, unless the filename is prefixed with an exclamation mark (!). In that case, the function overwrites any existing file with the same name.

Examples

collapse all

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

import matlab.io.*
fptr = fits.createFile("myfile.fits");
fits.createImg(fptr,"uint8",[256 512])
fits.closeFile(fptr)

Examine the file metadata and then delete the file.

fitsdisp("myfile.fits")
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  =                  512 / length of data axis 1
	NAXIS2  =                  256 / 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
delete myfile.fits

Tips

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