www.gusucode.com > wavelet 源码程序 matlab案例代码 > wavelet/ReconstructElNinoDataFromTimePeriodExample.m

    %% Reconstruct Data from Specific Time Period
% Use the inverse continuous wavelet transform to reconstruct an
% approximation to El Nino data based on 2 to 8 year periods.
%%
% Load the El Nino data and obtain its CWT. The data is sampled monthly.
% To obtain the periods in years, specify the sampling interval as
% 1/12 of a year. 
load ninoairdata;
[cfs,period] = cwt(nino,years(1/12));
%%
% Obtain the inverse CWT for periods of 2 to 8 years.
xrec = icwt(cfs,period,[years(2) years(8)]);

%%
% Plot the CWT of the reconstructed data and compare it to the CWT of the
% original data.
cwt(nino,years(1/12)); title('Original Data');
figure;
cwt(xrec,years(1/12)); title('Approximation Based on 2-8 Year Periods');

%%
% Compare the original data with the reconstructed data in time.
figure;
subplot(211)
plot(datayear,nino); 
grid on;
ax = gca;
ax.XTickLabel = '';
axis tight;
title('Original Data');

subplot(212)
plot(datayear,xrec); 
grid on;
axis tight;
xlabel('Year');
title('El Nino Data - 2-8 Year Periods');