How can I do 1D convolution on a 880*1 feature with filter size 45*1 with stride of 42?

1 次查看(过去 30 天)
I have a 885*1 feature and I would like to do a convolution with 45*1 with stride 42.
I want to get a 21*1 feature as a result.
If input layer(885*1) is named A, what sholud be the code?

回答(1 个)

Matt J
Matt J 2020-7-19
编辑:Matt J 2020-7-19
You can create a weight matrix that computes the convolution using func2mat on the File Exchange
For example,
>> k=rand(45,1);
>> C=func2mat(@(z) conv(z,k,'valid'),rand(885,1));
>> C=C(1:42:end,:);
>> whos C
Name Size Bytes Class Attributes
C 21x885 22208 double sparse
If you wish, you can verify that C*x gives the equivalent convolution as follows,
>> x=rand(885,1);
>> y1=conv(x,k,'valid'); y1=y1(1:42:end);
>> y2=C*x;
>> norm(y1-y2)
ans =
1.2809e-14

类别

Help CenterFile Exchange 中查找有关 Filter Analysis 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by