Average value and RMS value
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numerical Integration and Differentiation 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!