Convolution Computations results for a system response.
조회 수: 2 (최근 30일)
이전 댓글 표시
Prasad Edirisuriya Mudiyanselage
2019년 9월 16일
댓글: Prasad Edirisuriya Mudiyanselage
2019년 9월 16일
Can anyone tell the difference of these plots that I used following two codes to plot the results of convolution computations given and need to know the reason for having following difference?
I have attached the results I got for these codes.
댓글 수: 0
채택된 답변
Bruno Luong
2019년 9월 16일
편집: Bruno Luong
2019년 9월 16일
You make few mistakes, indexing and flipping (see careful conv documentation, the subtility is there, though TMW never mention whereas CEIL or FLOOR must be applied on even-length kernel, shame on them).
This code will show the correction and match both calculations (roundoff beside)
n=[1:1:1000];
s=10*cos(0.05*n);
N=randn(1,1000);
x=s+N;
h=0.1*ones(1,10);
y = conv(x,h,'same'); % 'same'
yy = zeros(1,length(n));
for i = 1: length(n)
for j = 1:length(h)
k = i-j+ceil((length(h)+1)/2); % shift by ceil(...) which correspond to "same"
if k>=1 && k<=length(x) % overflow check
yy(i) = yy(i) + h(j)*x(k);
end
end
end
close all
figure
plot(yy)
hold on
plot(y)
Related post here
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!