How to take an integral symbolically and then convert it to type double?
Afficher commentaires plus anciens
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 commentaires
VBBV
le 16 Mai 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.
le 16 Mai 2023
Walter Roberson
le 16 Mai 2023
Modifié(e) : Walter Roberson
le 16 Mai 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.
le 16 Mai 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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Number Theory dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


