www.gusucode.com > signal 案例源码程序 matlab代码 > signal/SignalReconstructionViaInverseDiscreteCosineTransformExample.m
%% Signal Reconstruction via Inverse Discrete Cosine Transform % Generate a signal that consists of a 25 Hz sinusoid sampled at 1000 Hz % for 1 second. The sinusoid is embedded in white Gaussian noise with % variance 0.01. %% rng('default') Fs = 1000; t = 0:1/Fs:1-1/Fs; x = sin(2*pi*25*t) + randn(size(t))/10; %% % Compute the discrete cosine transform of the sequence. Determine how many % of the 1000 DCT coefficients are significant, that is, greater than 1. y = dct(x); sigcoeff = abs(y)>=1; howmany = sum(sigcoeff) %% % Reconstruct the signal using only the significant components. y(~sigcoeff) = 0; z = idct(y); %% % Plot the original and reconstructed signals. subplot(2,1,1) plot(t,x) yl = ylim; title('Original') subplot(2,1,2) plot(t,z) ylim(yl) title('Reconstructed')