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

조회 수: 3 (최근 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