How can I implement these for loops efficiently using covolution?
이전 댓글 표시
I have this code
for xx=1:length(x)
for kk=1:length(x)
xSinc(xx) = xSinc(xx)+x(kk)*sinc(xx-kk-delta/T);
end
end
How can implement this efficiently using convultion in MATLAB?
댓글 수: 1
Torsten
2023년 8월 1일
If you don't know how to spell the method, you'd better stick to your loop solution.
채택된 답변
추가 답변 (1개)
Use conv
x = (0:0.2:5).^2;
L = 3;
delta = rand; T = rand;
% Your method
xSinc = zeros(size(x));
for xx = 1:length(x)
for kk=max(xx-L,1):min(xx+L,length(x))
xSinc(xx) = xSinc(xx)+x(kk)*sinc(xx-kk-delta/T);
end
end
xSinc
% conv method
xSinc2 = conv(x, sinc((L:-1:-L)+delta/T), 'same')
norm(xSinc2-xSinc)
plot(xSinc, 'b')
hold on;
plot(xSinc2, 'r.')
댓글 수: 3
MAWE
2023년 8월 23일
MAWE
2023년 8월 23일
Bruno Luong
2023년 8월 23일
편집: Bruno Luong
2023년 8월 25일
Have you tried to do some study of the code or you just ask without study conv?
카테고리
도움말 센터 및 File Exchange에서 Dynamic System Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
