How to take an integral symbolically and then convert it to type double?
古いコメントを表示
How do I take the following integral symbolically? And convert it to double? I have a 1000 x 1 numeric vector of type double for A(t).
The following takes a minute or two to run and I'm not sure how to plot it to check.
syms t omega real
int(A*sin(omega*t),0,2*pi/omega)
6 件のコメント
VBBV
2023 年 5 月 16 日
Since you have vector A as type numeric, the resulting integral for the expression sin(omega*t) between the limits 0 and (2*pi / omega) will always be zero.
L'O.G.
2023 年 5 月 16 日
Walter Roberson
2023 年 5 月 16 日
編集済み: Walter Roberson
2023 年 5 月 16 日
syms t omega real
A = rand(5,1);
Asym = sym(A);
int(Asym*sin(omega*t),0,2*pi/omega)
Symbolic integration but the result is exactly 0 anyhow.
Note that the A* part is a constant compared to t or any function of t, so the A* can be moved outside the integration, making it A*int(sin(omega*t),0,2*pi/omega) . But the integral of that sine epression is 0
syms tau;
int(sin(tau*t), 0, 2*pi/omega)
when tau = omega then that is sin(pi*1) which is 0.
L'O.G.
2023 年 5 月 16 日
format long g
syms t omega real
A = rand(5,1)
Asym = sym(A);
symbolic_result = int(Asym*sin(omega*t),0,2*pi/omega)
omega = abs(randn())
numeric_result = integral(@(t) A .* sin(omega.*t), 0, 2*pi./omega, 'Arrayvalued', true)
Zero to within round-off error.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


