What is the difference between using conv function and manual coding method using MATLAB?

1 回表示 (過去 30 日間)
Chalaka Perera
Chalaka Perera 2019 年 9 月 16 日
編集済み: Bruno Luong 2019 年 9 月 16 日
Here I Have mentioned two different options and the option 01 has used conv function and the option 02 has used manual coding method to find discrete Convolution.
Option 1
clc
clear all
close all
n = 1: 1: 1000;
N = randn (1,1000);
s = 10*cos(0.05*n);
figure (1)
plot (s,'r')
x = s + N;
figure (2)
plot (x,'g')
h = 0.1*ones(1,10);
y1=conv (x,h);
figure (3)
plot (y1)
figure (4)
plot (s,'r')
hold on
plot (x,'g')
hold on
plot (y1)
Option 2
m = length (x);
n = length (h);
X = [x,zeros(1,n)];
H = [h,zeros(1,m)];
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
figure (5)
plot (Y);
hold on

回答 (1 件)

Bruno Luong
Bruno Luong 2019 年 9 月 16 日
編集済み: Bruno Luong 2019 年 9 月 16 日
Your twin brother/sister/class mate is faster, he/she asked the same question earlier.
Don't copy the same answer, your teacher might notice it.

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by