function [DH, l, coeffsm] = DWT_temp(x, sampling_freq)
max_reached = 0;
sig = [x zeros(1, 2^ceil(log2(length(x))) - length(x))];
sig2 = sig;
tv = 0:length(sig2)-1;
tv = (1/sampling_freq)*tv;
diffs_v = [];
diffs_l_v = [];
l_c = 1;
while max_reached == 0,
[sums, diffs] = s_c(sig');
diffs_l = length(diffs);
sums_l = length(sums);
diffs_v = [diffs' diffs_v];
diffs_l_v = [diffs_l diffs_l_v];
l_c = l_c + 1;
if sums_l == 1
max_reached = 1;
end
sig = sums';
end
subplot(311), plot(tv, sig2); grid; title('Signal');
xlabel('time'); ylabel('amplitude'); axis tight;
DH = [sums' diffs_v];
subplot(312), plot(1:length(DH), DH); grid; title('DWT');
axis tight;
l1 = [sums_l diffs_l_v];
coeff_mat = zeros(length(l1), l1(length(l1)));
sfv = [];
sf = sampling_freq/2;
for sn = 1:length(l1)
sf1 = 3*(sf/4);
sfv = [sf1 sfv];
sf = sf1;
end
for row_c = 1:length(l1)
row_step_limit = round(l1(length(l1))/l1(row_c));
coeff_c = [ones(1, row_c-1) zeros(1, length(l1)-row_c
+ 1)];
row_step_c = 1;
pix_coeff_c = 0;
for pix_c = 1:l1(length(l1))
pix_coeff_c = pix_coeff_c + 1;
index = sum(coeff_c.*l1)
+ row_step_c;
new_value = DH( index );
coeff_mat(row_c, pix_c) = new_value;
if pix_coeff_c == row_step_limit
row_step_c =
row_step_c + 1;
pix_coeff_c
= 0;
end
end
end
subplot(313), imagesc(tv, sfv, coeff_mat);
title('DWT'); xlabel('time'); ylabel('frequency (Hz)');
axis xy;
l = l1;
coeffsm = coeff_mat;
DWT of chirp signal
DWT of displacement signal