Bru*_*lza 3 matlab wolfram-mathematica wolframalpha
我正在尝试计算卷积
x(t) = 1, -1<=t<=1
x(t) = 0, outside
Run Code Online (Sandbox Code Playgroud)
与自己使用定义.
http://en.wikipedia.org/wiki/Convolution
我知道如何使用Matlab函数转换,但我想使用积分定义.我对Matlab和WolframAlpha的了解非常有限.
我自己还在学习Mathematica,但这就是我想出来的......
首先我们定义分段函数(我使用维基百科页面中的示例)
f[x_] := Piecewise[{{1, -0.5 <= x <= 0.5}}, 0]
Run Code Online (Sandbox Code Playgroud)

让我们绘制函数:
Plot[f[x], {x, -2, 2}, PlotStyle -> Thick, Exclusions -> None]
Run Code Online (Sandbox Code Playgroud)

然后我们编写定义f自身卷积的函数:
g[t_] = Integrate[f[x]*f[t - x], {x, -Infinity, Infinity}]
Run Code Online (Sandbox Code Playgroud)

和情节:
Plot[g[t], {t, -2, 2}, PlotStyle -> Thick]
Run Code Online (Sandbox Code Playgroud)

我尝试在MATLAB/MuPad中做同样的事情,我没有那么成功:
f := x -> piecewise([x < -0.5 or x > 0.5, 0], [x >= -0.5 and x <= 0.5, 1])
Run Code Online (Sandbox Code Playgroud)

plot(f, x = -2..2)
Run Code Online (Sandbox Code Playgroud)

但是当我尝试计算积分时,返回这个花了将近一分钟:
g := t -> int(f(x)*f(t-x), x = -infinity..infinity)
Run Code Online (Sandbox Code Playgroud)

情节(也花了太长时间)
plot(g, t = -2..2)
Run Code Online (Sandbox Code Playgroud)

请注意,在MATLAB内部可以使用以下语法完成相同的操作:
evalin(symengine,'<MUPAD EXPRESSIONS HERE>')
Run Code Online (Sandbox Code Playgroud)