convolution without conv function
25 views (last 30 days)
Show older comments
I want to convolution of two continuous signals without using conv.
so i code
k= -10 : 0.01 : 10;
t= -10 : 0.01 : 10;
h= @(k,t) (k>=1);
x= @(k,t)(k>=-1).*(k<=1);
y1= int(x(k).*h(-k+t),k,-10,10);
y2= int(h(k).*x(-k+t),k,-10,10);
subplot(4,1,1);plot(k,x(k));
subplot(4,1,2);plot(k,y(k));
subplot(4,1,3);plot(t,y1);
subplot(4,1,4);plot(t,y2);
but there is problem y1 and y2
integral error.
how to integral that?
𝑥(𝑡) = 𝑟𝑒𝑐𝑡 ( 𝑡/ 2 ) , ℎ(𝑡) = 𝑢(𝑡 − 1)
y(t) = integral this x(r)h(t -r )dr (form -10 to 10)
2 Comments
Dyuman Joshi
on 9 Apr 2023
int is used for symbolic integration.
You have defined "t" and "k" as the independent variables, but you have only used "k" in the definition, so any value of "t" will not have any effect on the outcome.
Answers (3)
Paul
on 9 Apr 2023
Edited: Paul
on 9 Apr 2023
Questions like this are fairly common on this forum. A closed form expression can be obtained using
Here is a similar Question with answer that may be of interest to adapt to this problem.
0 Comments
Matt J
on 9 Apr 2023
syms z k t real
h(z)= piecewise(z>=1,1,0);
x(z)= piecewise(abs(z)<=1,1,0);
y1= int(x(k).*h(t-k),k,-10,10)
y2= int(h(k).*x(t-k),k,-10,10)
1 Comment
Paul
on 9 Apr 2023
Despite the statement in the question, I suspect that the problem is to find the convolution of x(t) and h(t) for -10 <= t <= 10. But that's not the same as integrating over that interval. That interval works fine for y1 because it covers the entire interval where x(t) ~= 0, but not for y2, which is why y1 and y2 are not the same.
I guess more clarity on the question is needed.
Image Analyst
on 9 Apr 2023
Attached is a "manual" way to do convolution. It will be straightforward to adapt it from 2-D images to 1-D vectors if you want.
0 Comments
See Also
Categories
Find more on Calculus 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!