Main Content

matlab.io.fits.movRelHDU

Move relative number of HDUs from current HDU

Syntax

htype = moveRelHDU(fptr,nmove)

Description

htype = moveRelHDU(fptr,nmove) moves a relative number of HDUs forward or backward from the current HDU and returns the HDU type, htype, of the resulting HDU. The possible values for htype are:

'IMAGE_HDU'
'ASCII_TBL'
'BINARY_TBL'

This function corresponds to the fits_movrel_hdu (ffmrhd) function in the CFITSIO library C API.

Examples

Move through each HDU in succession, then move backwards twice by two HDUs.

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
htype = fits.movRelHDU(fptr,-2);
n = fits.getHDUnum(fptr);
fprintf('HDU %d:  "%s"\n',n,htype);
htype = fits.movRelHDU(fptr,-2);
n = fits.getHDUnum(fptr);
fprintf('HDU %d:  "%s"\n',n,htype);
fits.closeFile(fptr);