%% %% Code for demos presented in lecture 3 %% %% %% Variable shape signal experiment %% MAX_SIG_LEN = 32; MAX_JITTER = 14; BLIP_LENGTH = 2; N = 400; S = zeros(N,MAX_SIG_LEN); for EE=1:N, %% Generate signal xx = round(MAX_JITTER*rand(1,2))+[1 MAX_SIG_LEN-MAX_JITTER]; S(EE,xx(1)+[1:BLIP_LENGTH])=-1-rand; S(EE,xx(2)-[1:BLIP_LENGTH])=+1+rand; %S(EE,:) = S(EE,:) - mean(S(EE,:)); end; for i=1:16, figure(5); subplot(4,4,i); plot(S(i,:)); end; %MS = mean(S); %S = S - ones(N,1)*MS; [U,SS,V] = svd(S'*S); figure(6); sval = diag(SS); semilogy(sval(1:16),'.','MarkerSize',15); for i=1:16, figure(7); subplot(4,4,i); plot(U(:,i)); end; %% Projection of signals onto new base for EE=1:N, c1(EE) = S(EE,:) * U(:,1); c2(EE) = S(EE,:) * U(:,2); end; figure(8); plot(c1,c2,'.','MarkerSize',15); xlabel('1st component'); ylabel('2nd component'); title(['The ' num2str(N) ' sample signals projected onto the reduced base']);