Convolution without conv() function

Hi everybody,
I have a issue to plot a convolution without using the conv() function.
I have x1=sin(2*pi*f1*n*T) and x2=cos(2*pi*f2*n*T)
And i have to plot x3[n] = x1[n] conv x2[n]
I tried many different function like sum, int, symsum but i don't succeed to do it. Is there someone that can help me please
Thank you very much

11 件のコメント

John D'Errico
John D'Errico 2015 年 4 月 11 日
Surely you can write down the convolution on paper as a sum?
So now write it using a loop.
Geoff Hayes
Geoff Hayes 2015 年 4 月 11 日
jackal's answer moved here
Can i use a function a sum fonction that will make it?
Or do i have to make a loop because i need to plot it after.
Thank you
John D'Errico
John D'Errico 2015 年 4 月 11 日
No. You cannot write it just with a single call to the function sum. You can write it using a loop and a call to sum, or using a nested pair of for loops.
Just take the formula for a convolution. Then see how it would work using a loop.
Matt J
Matt J 2015 年 4 月 11 日
jackal's answer moved here
First, thank you a lot for your help.
The teacher gives us as information that for the conv we have to use the formula:
x3[n] = sum for m from -infinity to infinity of x1[n-m]*x2[m]
I don't know how i can represent the infinity sum?
Thank you
Manolis Michailidis
Manolis Michailidis 2015 年 4 月 11 日
First i suppose you could say m=1:INF and shift it in a loop every time, the discrete covolution formoula should be ok i think , as for the sum should be computed in the nested loop , so basically you will calculate a new array .
Geoff Hayes
Geoff Hayes 2015 年 4 月 11 日
Jackal's answer moved here
So basically i ll have to calculate for n = 0 to for example 10 and put the result in a array?
Or do i misunderstand?
Geoff Hayes
Geoff Hayes 2015 年 4 月 11 日
@Jackal - if you wish to further the conversation please comment on the above remarks rather than creating answers (which aren't answers to your question).
jackal dr
jackal dr 2015 年 4 月 11 日
oh!! Ok sorry i didn't know how it works ^^
Manolis Michailidis
Manolis Michailidis 2015 年 4 月 11 日
Yes for example if your signal has lenght n=10 samples you will start for i=1:n+1 (matlab indexing starts from 1) and then yous should calculate in each iteration the sum of your signal with the shifted other , there is a function that does what you are asking take a look http://www.mathworks.com/matlabcentral/fileexchange/23402-convolution-in-matlab-without-using-conv-x-h-
jackal dr
jackal dr 2015 年 4 月 11 日
Thank you a lot
I will try it and if i have other inquiries i ll ask.
Thank you very much for your time.
Hope i ll suceed ^^
Image Analyst
Image Analyst 2015 年 4 月 11 日
If he won't let you use conv(), then why would he let you use sum()? Seems inconsistent. http://www.mathworks.com/matlabcentral/answers/38787-what-can-be-programmed-without-any-built-in-functions

サインインしてコメントする。

回答 (1 件)

Sk Group
Sk Group 2021 年 10 月 25 日

0 投票

Convolution without conv function in MATLAB | Complete CODE | Explanation | Example And Output

質問済み:

2015 年 4 月 11 日

回答済み:

2021 年 10 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by