This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create FITS image




createImg(fptr,bitpix,naxes) creates a new primary image or image extension with a specified datatype bitpix and size naxes. If the FITS file is currently empty then a primary array is created, otherwise a new image extension is appended to the file.

The first two elements of naxes correspond to the NAXIS2 and NAXIS1 keywords, while any additional elements correspond to the NAXIS3, NAXIS4 ... NAXISn keywords.

Specify the datatype bitpix as a character vector or string scalar containing either a CFITSIO name or the corresponding MATLAB® datatype.


This function corresponds to the fits_create_imgll(ffcrimll) function in the CFITSIO library C API.


Create two images in a new FITS file. There are 100 rows (NAXIS2 keyword) and 200 columns (NAXIS1 keyword) in the first image, and 256 rows (NAXIS2 keyword), 512 columns (NAXIS1 keyword), and 3 planes (NAXIS3 keyword) in the second image.

fptr = fits.createFile('myfile.fits');
fits.createImg(fptr,'int16',[100 200]);
fits.createImg(fptr,'byte_img',[256 512 3]);