How can I Implement a convolution function in MATLAB and perform it on the following signals and plot the results ?
Show older comments
Hi guys,
I have the following function:
impulse_response = zeros(1, length(input) + length(delta) - 1 );
for t_samp = 1:length(input)
for c_samp = 1:length(delta)
index = t_samp + c_samp - 1;
value = delta(c_samp) * input(t_samp);
impulse_response(index) = impulse_response(index) + value;
end
end
I am new to Matlab and I want to understand how to Implement a convolution function in MATLAB and perform it on the following signals and plot the results ?
Task (1):
x[n] = [1,1,1,1] h[m] = [1,0,−1] x[n] = sin(n) h[m] = [−1,−2,8,−2,−1] 20 ≤ n < 20
Task (2): Given the input signal x[n]=0.3∗sin(n/5)+sin(n/50) : -Create your own delta signal h[m] that removes the higher frequency sinusoidal component to get yl[n].
Thanks in advance for your kind explanation.
2 Comments
Walter Roberson
on 14 Mar 2018
Could you confirm that your n values are radians and not degrees?
Vaban Dust
on 15 Mar 2018
Accepted Answer
More Answers (3)
Abhishek Ballaney
on 15 Mar 2018
Edited: Walter Roberson
on 20 Oct 2020
1 vote
Ankur Agrawal
on 21 Sep 2021
Edited: Walter Roberson
on 29 Dec 2021
n = -20:20;
x = sin(n);
h = [-1,-2,8,-2,-1];
N = length(x);
M = length(h);
Ny = N + M -1;
y = zeros(1,Ny);
for i = 1:N
for k = 1:M
y(i+k-1) = y(i+k-1) + h(k)*x(i);
end
end
m = 0: Ny-1;
Abdullah Mohmmed
on 29 Dec 2021
0 votes
Write a MATLAB code to calculate and plot the two-sided convolution between the two discrete time signals x(n) and h(n) shown below
1 Comment
Walter Roberson
on 29 Dec 2021
No signal definitions were shown.
And if they had been, we would have just referred you to the discussion above, which includes full code.
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
