Convolution without using conv; show table as if doing it on paper
10 ビュー (過去 30 日間)
古いコメントを表示
I need to calculate a convolution of a user entered data and do so without using the conv command. I then need to show a table of the steps in which the convoultion is calculated by hand, as if doing it paper. A homework checker essentially. The way you calculate it on hand is as shown here: 

I found 2 ways of calculating conv without using he literal conv commmand. They are as follows;
%%
x=input('Enter the coefficients for x (surround with []): ')
h=input('Enter the coefficients for h (surround with []): ')
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
A = [X;H];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
%%
x=input('Enter the coefficients for x (surround with []): ');
h=input('Enter the coefficients for h (surround with []): ');
x = x';
h=h';
N = length(x)+length(h)-1;
x1 = [x; zeros(N-length(x),1)]
h1 = [h; zeros(N-length(h),1)]
filter(x1, 1, h1)
I'm really at a loss as to how to show the table. I tried creating one (A) in the first method but cant figure out how to get the calculation lines to output. It does show the X and H values
4 件のコメント
Steven Lord
2021 年 4 月 27 日
Do you just want to display the intermediate steps or do you want to store them in some sort of variable?
David Goodmanson
2021 年 4 月 27 日
Hi Maria,
the convolution has length(x) + length(h) - 1 = 8 elements. If you zerofill x so that it has 8 elements
x = [x zeros(1,3)];
then using
x = circshift(x,1)
at each step will progressively shift x to the right, putting harmless placeholder zeros into the unneeded array elements. After that there are some details to complete the process.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!