Simple question about plotting a convolution
Mostrar comentarios más antiguos
I have two sets of data (x,y1) and (x,y2).I need to calculate the convolution between y1 and y2 and plot it vs x. Is it correct to do simply like this?
convol=conv(y1,y2);
plot(x,convol)
I've never used the command conv and I'm not sure about it. Thanks!
Respuesta aceptada
Más respuestas (1)
Andrew Newell
el 25 de Mzo. de 2015
Editada: Andrew Newell
el 25 de Mzo. de 2015
Your code will give you a vector of length length(y1)+length(y2)-1, so you'll get an error if you plot it against x (which is presumably the same length as y1 and y2). Instead, use
convol = conv(y1,y2,'same')
which gives you the central part of the convolution of the same size as y1. Then you'll be able to plot it.
1 comentario
aurc89
el 25 de Mzo. de 2015
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!