Hello I am having trouble plotting this convolution. my error is "Vectors must be the same length."
Show older comments
if true
% code
end
n= -60:60;
xn= cos(n/10);
h = zeros(size(n));
h(abs(n)<=10) = 1/21;
xn1= conv(xn,h);
plot(n,xn1);
3 Comments
George
on 8 Sep 2016
Are you sure n is defined correctly? It looks like you're trying to make an array, but you're making a scalar.
robert Griffin
on 8 Sep 2016
robert Griffin
on 8 Sep 2016
Answers (1)
Thorsten
on 8 Sep 2016
1 vote
Use conv for convolution. cov computes the covariance matrix.
2 Comments
robert Griffin
on 8 Sep 2016
Thorsten
on 9 Sep 2016
Just use
xn1= conv(xn,h, 'same');
and everything's alright.
Categories
Find more on MATLAB 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!