convolution without conv function

5 次查看(过去 30 天)
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 个评论
Dyuman Joshi
Dyuman Joshi 2023-4-9
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.
찬경
찬경 2023-4-9
It is understood that if the two variable expressions are positively integrated for one variable, the equation of the remaining variable becomes. I don't know how to code this kind of situation like this. Originally, the expression is one variable, but I am thinking of adding one variable only when integrating.

请先登录,再进行评论。

回答(3 个)

Paul
Paul 2023-4-9
编辑:Paul 2023-4-9
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.

Matt J
Matt J 2023-4-9
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)
Warning: Unable to check whether the integrand exists everywhere on the integration interval.
y1 = 
y2= int(h(k).*x(t-k),k,-10,10)
Warning: Unable to check whether the integrand exists everywhere on the integration interval.
y2 = 
  1 个评论
Paul
Paul 2023-4-9
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
Image Analyst 2023-4-9
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.

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by