How to take an integral symbolically and then convert it to type double?
Mostrar comentarios más antiguos
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 comentarios
VBBV
el 16 de Mayo de 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.
el 16 de Mayo de 2023
Walter Roberson
el 16 de Mayo de 2023
Editada: Walter Roberson
el 16 de Mayo de 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.
el 16 de Mayo de 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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Number Theory en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


