How to take an integral symbolically and then convert it to type double?
Show older comments
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 Comments
VBBV
on 16 May 2023
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.
on 16 May 2023
Walter Roberson
on 16 May 2023
Edited: Walter Roberson
on 16 May 2023
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.
on 16 May 2023
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.
Accepted Answer
More Answers (0)
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

