Convolution of absolute magnitude =/= absolute magnitude of convolution?

8 visualizaciones (últimos 30 días)
I'd like to figure out what I'm doing wrong to cause this issue.
Consider the code below:
A = [0.008912 0.0008934 -0.002584 0.003039 -0.002209 0.0007542 0.0005372 -0.0003424 -0.009147 0.03952 -0.05169 -0.07655 0.3637 -0.5018 0.1533 0.4625 -0.7134 0.3894 0.06538 -0.2249 0.1327 -0.02629 -0.006015 0.003311 0.000262 -0.0007913 0.0005139 0 -0.0004398 0.0005598 -0.0003478];
B = [-0.0017 0.002354 -0.001407 -0.0003384 0.001932 -0.002653 0.002321 -0.0002952 -0.003325 -0.01342 0.09965 -0.219 0.149 0.2581 -0.682 0.597 -0.02179 -0.4432 0.42 -0.1383 -0.04043 0.05345 -0.01858 0.002102 0 0.0003302 0 0 0 0 0];
H = [0.1986 0.4934 0.6589 0.4934 0.1986];
C = A + B*1j;
plot(abs(conv(C,H,'same')));
hold on;
plot(conv(abs(C),H,'same'));
Why are the two plots different? I thought
Am I missing something simple? Thanks for the help!

Respuesta aceptada

Rik
Rik el 12 de Jun. de 2019
Let's consider a minimal example:
data=[-3 0 3];
kernel=[1 1 1]/3;
Now it is easy to see that convolving first and then taking the absolute value will do something different than doing them in reversed order.
data=[-3 0 3];
kernel=[1 1 1]/3;
conv_first=conv(data,kernel,'same');%result: [-1 0 1]
conv_first=abs(conv_first)
%conv_first=[1 0 1]
data=abs(data);
abs_first=conv(data,kernel,'same')
%abs_first=[1 2 1]
I can't pinpoint where your math is wrong, but it must be wrong somewhere. Probably the second step, as you're doing multiple operations there at once, not all of which I understand.

Más respuestas (2)

Shivam Sardana
Shivam Sardana el 12 de Jun. de 2019
Please look at More About section of conv function.

Nathan Jessurun
Nathan Jessurun el 14 de Jun. de 2019
That makes sense, thanks. It looks like I messed up when I put the magnitude operator in the summation.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by