I'm trying to apply a DWT with 3 composition levels and the following question arose when calculating the composition matrix. The step I'm trying to follow is:

The DWT coefficientes are obtained from filtering operations and are divided in approximation ($cA$) and detail coefficients ($cD$).

Three Decomposition Level of DWT

If a signal $f(n)$ is scaled up to a defined decomposition level, then, it will be producing a wavelet matrix $M(J+1,n)$, this matrix is analysed using its correlation matrix defined by:

$$ \boldsymbol{Y}=\frac{\boldsymbol{M} \times \boldsymbol{M}^T}{n} $$

where $n$ is the total sample numbers. Therefore, it has a matrix $Y(J+1,J+1)$ which contains the scaled frequency information of the signal.

Each level of decomposition will have a matrix with a different size, so how am I going to analyze the correlation matrix? Should it be done individually? Should I complete with zeros? Should I only analyze $cD_3$ AND $cA_3$?

For example, for a discrete signal that I am applying dwt MATLAB toolbox. It will first generate a $cD_1$ (9x1), $cD_2$ (6x1), $cD_3$ (4x1) and $cA_3$ (4x1).

Each coefficient has a different size.

Reference Algorithm for transformer differential protection based on wavelet correlation modes


for i = 1:num_windows
current_start_index = start_index + (i - 1) * step_size;
current_end_index = current_start_index + half_cycle_samples - 1;

windowed_Ida(:, i) = Ida_n(current_start_index:current_end_index);
windowed_Idb(:, i) = Idb_n(current_start_index:current_end_index);
windowed_Idc(:, i) = Idc_n(current_start_index:current_end_index);
  swc_a = swt(windowed_Ida(:, i),3,"db4");
  n_a = length(swc_a);
  Y1 = (swc_a * swc_a') / n_a;
  swc_b = swt(windowed_Idb(:, i),3,"db4");
  n_b = length(swc_b);
  Y2 = (swc_b * swc_b') / n_a;
  swc_c = swt(windowed_Idc(:, i),3,"db4");
  n_c = length(swc_c);
  Y3 = (swc_b * swc_b') / n_a;
  YT = (Y1 + Y2 + Y3)/3;

  D = eig(YT);
  MCW(start_index + (i - 1) * step_size : start_index + (i - 1) * step_size + half_cycle_samples - 1) = max(D);


  • $\begingroup$ Can you share the reference on this correlation matrix? $\endgroup$
    – Jdip
    Commented Mar 6 at 17:47
  • $\begingroup$ Of course, link $\endgroup$
    – Dragnovith
    Commented Mar 6 at 17:48
  • $\begingroup$ Is $J$ the decomposition level? What type of analysis are you trying to do with the correlation matrix? $\endgroup$
    – Baddioes
    Commented Mar 6 at 17:49
  • $\begingroup$ J is the decomposition level $\endgroup$
    – Dragnovith
    Commented Mar 6 at 17:50
  • $\begingroup$ The signal I am analyzing is formed by a vector (7680x1). With 32 samples per cycle. $\endgroup$
    – Dragnovith
    Commented Mar 6 at 17:55

1 Answer 1


The paper you linked to is problematic, with lots of typos (e.g, the size of this "wavelet" instead of the size of this "matrix"), and no information on how they actually build this "wavelet matrix".

The most straight-forward way to go about it is to use a Stationary Wavelet Transform, which gets rid of the downsampling operation at each stage, giving you coefficients $cA_i$ and $cD_i$ of the same length, allowing you to build that matrix easily (assuming you know which order these should be stacked).

  • $\begingroup$ I applied the MATLAB swt function, it generated a matrix M(J,n) and not M(J+1,n). Will I have problems with this? $\endgroup$
    – Dragnovith
    Commented Mar 6 at 22:32
  • $\begingroup$ Based on the documentation, if you call swc=swt(x,J,wname), you should get a matrix swc of size (J+1,n). $\endgroup$
    – Jdip
    Commented Mar 6 at 22:51
  • $\begingroup$ I'm still trying to apply the paper's algorithm. But without success. I put the algorithm in the post. $\endgroup$
    – Dragnovith
    Commented Mar 8 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.