Basic Integration from negative infinity to a variable
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
David Goodmanson
am 29 Mai 2020
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.
Antworten (1)
Surya Talluri
am 11 Aug. 2020
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 Kommentare
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!