Performing convolution - 3 signals are convolving with three corresponding signal ?

10 views (last 30 days)
I have attached the data and facing a following problem.
In a first step I am convolving a wav (101 x 1) with trc (101 x 3) e.g., a single wav is being convolved three trc vectors (of equal number of rows) and giving three outputs. I am using following code and it is working:
synth = conv2(wav_near', trc);
t0_i = floor(t0/dt); Nl = 101;
synth = synth(1+t0_i:Nl+t0_i,:);
Now, I have three wav (108 3) and want to convolve with trc (120 3) in way like the first wav will convolve with first trc, second wav with second trc and so on. I have attached all the three wav (wav_near, wav_mid, wav_far) and trc. I tried a lot of combinations but they are not working. How can I change the above code in this case?
The size of outcomes should be the size of trc.
One way I tried like but results are not same
synth = zeros(120, 3);
% Loop through each column
for col = 1:3
conv_result = conv2(wav(:, col), trc(:, col), 'full')
start_idx = floor((length(wav(:, col)) - 1) / 2) + 1;
end_idx = start_idx + 120 - 1;
synth(:, col) = conv_result(start_idx:end_idx);
end

Answers (2)

Ahmed
Ahmed on 23 Jun 2024
I find a way to do it and it is working.
synth = zeros(Nl, 3);
% Loop through each column
for col = 1:3
conv_result = conv2(wav(:, col), trc(:, col));
synth(:, col) = conv_result(1 + t0_i:Nl + t0_i);
end

Image Analyst
Image Analyst on 23 Jun 2024
The result of a normal, full convolution is the sum of the extents of the two waveforms. You can automatically crop to the length of the first argument (vector) if you use the 'same' option. This is usually used when the first vector is a long signal, and the second vector is a short vector that is the filter window.

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!