How to take an integral symbolically and then convert it to type double?
1 回表示 (過去 30 日間)
古いコメントを表示
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).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1384539/image.png)
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 件のコメント
Walter Roberson
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.
採用された回答
VBBV
2023 年 5 月 16 日
編集済み: VBBV
2023 年 5 月 16 日
syms t omega real
A = rand(1000,1);
% specify the integration variable t as the argument
I = double(vpa(int(A.*sin(omega*t),t,0,2*pi/omega),2))
1 件のコメント
VBBV
2023 年 5 月 16 日
Assuming some random data, you can specify the integration variable t as the argument and do symbolic integration
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!