Average value and RMS value
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
David Perez Ramos
le 2 Mar 2015
Réponse apportée : Star Strider
le 2 Mar 2015
Hello, I am trying to verify functions taking the average and RMS value using trapz function,but I am not getting the right answer in matlab. according to the theory in the book the average value of a function is obtained by: 1/(b-a)∫〖5sin(t)〗, across the interval a<t<b. This is what I have done:
EDITOR:
%Verify that the average value for F(t)=5sin(t), is zero.
%Verify that the RMS value for F(t)=5sin(t), is 3.535.
function z= myfun2(t)
a = 1;
b = 3;
z =(1/b-a)*(5*sin(t)); %function for average value.
end
COMMAND WINDOW:
>> t = linspace(1,3,400);
>> z = myfun2(t);
>> average = trapz(t,z)
average =
-5.1010
When I do it by hand, I do get zero for the average value, but in matlab and dont get zero. Is something wrong in my z function?
0 commentaires
Réponse acceptée
Star Strider
le 2 Mar 2015
I’m guessing at what your problem actually says, but the problem may be the ‘a’ and ‘b’ limits. Adding pi to them as a factor, and correcting the definition of mean value:
myfun2 = @(t) 5*sin(t);
a = pi;
b = 3*pi;
t = linspace(a,b,400);
z = myfun2(t);
average = trapz(t,z)./(b-a)
produces:
average =
-95.6651e-018
which is essentially zero to floating-point precision.
The mean value is Integral(f(t),a,b)/(b-a).
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Numerical Integration and Differentiation 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!