On entry, | . |
Open in the MATLAB editor: c06gb_example
function c06gb_example fprintf('c06gb example results\n\n'); % real data n = 7; x = [0.34907 0.54890 0.74776 0.94459 1.13850 1.32850 1.51370]; % transform [xt, ifail] = c06ea(x); % get result in form useful for printing. zt = nag_herm2complex(xt); disp('Discrete Fourier Transform of x:'); disp(transpose(zt)); % restore by conjugating and backtransforming [xt, ifail] = c06gb(xt); [xr, ifail] = c06eb(xt); fprintf('Original sequence as restored by inverse transform\n\n'); fprintf(' Original Restored\n'); for j = 1:n fprintf('%3d %7.4f %7.4f\n',j, x(j),xr(j)); end function [z] = nag_herm2complex(x); n = size(x,2); z(1) = complex(x(1)); for j = 2:floor((n-1)/2) + 1 z(j) = x(j) + i*x(n-j+2); z(n-j+2) = x(j) - i*x(n-j+2); end if (mod(n,2)==0) z(n/2+1) = complex(x(n/2+1)); end
c06gb example results Discrete Fourier Transform of x: 2.4836 + 0.0000i -0.2660 + 0.5309i -0.2577 + 0.2030i -0.2564 + 0.0581i -0.2564 - 0.0581i -0.2577 - 0.2030i -0.2660 - 0.5309i Original sequence as restored by inverse transform Original Restored 1 0.3491 0.3491 2 0.5489 0.5489 3 0.7478 0.7478 4 0.9446 0.9446 5 1.1385 1.1385 6 1.3285 1.3285 7 1.5137 1.5137