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
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
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:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!