%% Example 3.2 % Here is a signal consisting of 4 cycles of sine followed by a step function. s = [sin([1:512]*8*pi/512) ones(1,256) ones(1,256)/2] plot(s) xticks([0 256 512 768 1024]) xticklabels({'0','256','512','768','1024'}) axis([0 1024 -1.5 1.5]) %% % Here it is with added noise. %% s10 = [sin([1:512]*8*pi/512) ones(1,256) ones(1,256)/2]+0.1*randn(1,1024); %% plot(s10) xticks([0 256 512 768 1024]) xticklabels({'0','256','512','768','1024'}) axis([0 1024 -1.5 1.5]) title('random signal with noise') %% % Here is a plot of one-scale Haar transform of the signal, using the command % *haarwave *from Computer Exploration 3.7.4. %% plot(haarwave(s10,1)) xticks([0 256 512 768 1024]) xticklabels({'0','256','512','768','1024'}) axis([0 1024 -1.5 1.5]) title('one-scale Haar transform of signal') annotation('doublearrow',[0.13 0.52], [0.52 0.52]); annotation('doublearrow',[0.52 0.905],[0.52 0.52]); annotation('textbox',[0.32 0.42 0.11 0.06],... 'String',{'trend s_9'},'LineStyle','none'); annotation('textbox',[0.65 0.38 0.16 0.10],... 'String',{'detail s_9'},'LineStyle','none');