Basic Integration from negative infinity to a variable
10 ビュー (過去 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!