Convolution of Two Functions

3 次查看(过去 30 天)
jgillis16
jgillis16 2015-7-28
评论: Torsten 2015-7-29
I need to implement a function that is:
G(T) = integral(-inf,inf)[Y1(W1)*W1(X1+T)]dt
Code drafted so far is:
%fun = @ (Y1,X1,W1,XX1) Y1(X1).*W1(XX1);
%q = integral(fun, -inf, inf);
(where XX1 = X1 + 0.0001)
But, I keep getting the error message below:
Error using @(Y1,X1,W1,XX1)Y1(X1).*W1(XX1)
Not enough input arguments.
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 103)
[q,errbnd] = vadapt(@minusInfToInfInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in s27onepointone (line 73)
q = integral(fun, -inf, inf);
Any suggestions on how to proceed?

回答(2 个)

Torsten
Torsten 2015-7-28
G(T) = integral(-inf,inf)[Y1(W1)*W1(X1+T)]dt
makes no sense.
W1 is an independent variable in Y1(W1) and becomes a dependent variable in W1(X1+T).
The integration variable is t which does not appear in Y1(W1)*W1(X1+T).
Do you want to calculate the convolution of two functions ?
Best wishes
Torsten.
  1 个评论
jgillis16
jgillis16 2015-7-28
Apologies. Yes, a convolution would be precisely what I would be looking for as I need an integral that expresses the amount of overlap of one function g as it is shifted over another function f. The limits set were just basic limits I noted on an abstract note.

请先登录,再进行评论。


Steven Lord
Steven Lord 2015-7-28
The function you specify as the first input to the INTEGRAL function must accept 1 input vector. Your function accepts (indeed REQUIRES) 4 inputs. See the description of the fun input argument in that documentation page for more information.
Please be more specific about the mathematical problem you're trying to solve (describe what the various identifiers you're using in your code represent -- function, variable, etc.) If you do that you may be able to receive more guidance about how to perform the integration you want.
  2 个评论
jgillis16
jgillis16 2015-7-28
编辑:jgillis16 2015-7-28
The original integral I have is:
G(tau) = integral(-inf, inf) h_x(t)*h_+(t+tau)dt
where tau = T, h_x = Y1, h_+ = W1, and t = X1.
And: T = 0.0001, Y1 = 55488x1 double, W1 = 55488x1 double, X1 = 55488x1 double.
I will need to perform a convolution of the two given functions as I need to identify the overlap between two functions.
Hope this is clear enough.
Torsten
Torsten 2015-7-29
If your X1 vector is ordered, use the trapezoidal rule to evaluate the integral:
G(tau) = (Y1(t1)*W1(t1+tau)+Y1(t2)*W1(t2+tau))/2 * (t2-t1) +
(Y1(t2)*W1(t2+tau)+Y1(t3)*W1(t3+tau))/2 * (t3-t2) + ...+
(Y1(t55487)*W1(t55487+tau)+Y1(t55488)*W1(t55488+tau))/2 * (t55488-t55487)
To get W1(ti+tau), you will have to use interpolation.
Best wishes
Torsten.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by