Convolution of Two Functions
2 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
回答 (2 件)
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.
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 件のコメント
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!