Basic Integration from negative infinity to a variable

14 次查看(过去 30 天)
Hello all!
I have just started using MATLAB, so do bear with me.
I'm trying to intergerate the following function: exp(-x)*cos(2*pi*t) from negative infinity to t
So what I will is first declare the functionas fun1: fun1 = @(x)exp(-x)*cos(2*pi*t)
After which, I should do this: syms t (not sure what this does too, can anyone explain?)
Then I will do this where r is my output: r = integral (fun1,-Inf,t)
However it givees me an error: Error using integral (line 85)
A and B must be floating-point scalars.
Not sure what I did wrong, can anyone help? Thanks :)
  1 个评论
David Goodmanson
David Goodmanson 2020-5-29
Hi HW
Before you get to the code, I'm assuming you do mean exp(-x)*cos(2*pi*t) rather than exp(-x)*cos(2*pi*x). Then cos(2*pi*t) can be factored out of the integral since it's independent of x. That leaves the integral of exp(-x) from -infinity to t. But that integral is infinite, because the argument of the exponent is increasing as x --> -infinity.

请先登录,再进行评论。

回答(1 个)

Surya Talluri
Surya Talluri 2020-8-11
I understand that your lower limit is -Inf, it makes e^(-x) tends to Inf.
In MATLAB, you can create symbolic math variables using “syms” function and use “int” function to integrate the symbolic functions created.
syms t
fun1 = @(x)exp(-x)*cos(2*pi*t);
r = int(fun1,-Inf,t)
r =
Inf*(2*cos(pi*t)^2 - 1)
You can refer to following documentation for further understanding of Symbolic Math Toolbox:

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by