Main Content

matlab.io.fits.movRelHDU

Move relative number of HDUs from current HDU

Syntax

htype = matlab.io.fits.moveRelHDU(fptr,nmove)

Description

htype = matlab.io.fits.moveRelHDU(fptr,nmove) moves a relative number of HDUs forward or backward from the current HDU and returns the type of the resulting HDU. The function returns htype as 'IMAGE_HDU', 'ASCII_TBL', or 'BINARY_TBL'.

Examples

collapse all

Open a sample FITS file and display information about each HDU in the file.

import matlab.io.*
fptr = fits.openFile("tst0012.fits");
N = fits.getNumHDUs(fptr);

for j = 1:N
    htype = fits.movAbsHDU(fptr,j);
    fprintf('HDU %d: "%s"\n',j,htype)
end
HDU 1: "IMAGE_HDU"
HDU 2: "BINARY_TBL"
HDU 3: "IMAGE_HDU"
HDU 4: "IMAGE_HDU"
HDU 5: "ASCII_TBL"

Move the current HDU back by two and display its information.

htype = fits.movRelHDU(fptr,-2);
NN = fits.getHDUnum(fptr);
fprintf('HDU %d: "%s"\n',NN,htype)
HDU 3: "IMAGE_HDU"

Move the current HDU back by two more and again display its information.

htype = fits.movRelHDU(fptr,-2);
NN = fits.getHDUnum(fptr);
fprintf('HDU %d: "%s"\n',NN,htype)
HDU 1: "IMAGE_HDU"

Close the file.

fits.closeFile(fptr)

Tips

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