can i integrate this function using integral?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I tried to integrate a function using the integral command but it did not work. I also used trapz but I think i'm missing some key information.
I have a function as follows:
f(t) = from 0 to t sin(2*pi*x)e^-x dx
here is the code i have so far. i know it's wrong but i am not sure what to do :(
i was also given range of t from 0 to 10 having 100 points.
clc; clear all; close all;
t = 1:.001:10;
f= sin(2*pi.*t).*exp(-t);
plot(f)
Z=trapz(t)
0 commentaires
Réponses (2)
Roger Stafford
le 31 Oct 2014
You haven't shown us your code for using the 'integral' function, but your code for using 'trapz' has the right integrand function but the wrong limits of integration. These go from 1 to 10, not from 0 to a variable t, and involve 9001 points, not 100.
For the purpose of computing a function f(t) to express the integral from 0 to a variable t, it is infinitely preferable to use the known explicit solution for this integral.
As can be determined by looking in a good table of integrals or using the Symbolic Toobox function 'int' its indefinite integral is:
-exp(-x)/(1+4*pi^2)*(sin(2*pi*x)+2*pi*cos(2*pi*x)
so the definite integral from 0 to t would be
(2*pi-exp(-t)*(sin(2*pi*t)+2*pi*cos(2*pi*t)))/(1+4*pi^2)
0 commentaires
Star Strider
le 31 Oct 2014
You need to code ‘f’ as an anonymous funciton to use it with integral:
f= @(x) sin(2*pi.*x).*exp(-x);
0 commentaires
Voir également
Catégories
En savoir plus sur Integration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!