Incorrect numerical integration, how to fix?

1 visualización (últimos 30 días)
Tanner Sloan
Tanner Sloan el 12 de Feb. de 2020
Respondida: the cyclist el 12 de Feb. de 2020
I am trying to solve for the average and rms of a function, y(t), and upon numerical integration, I am not finding the correct answers.
MATLAB EDITOR:
% Determine the AVERAGE and RMS values for the function:
% y(t) = 25 + 10sin6pi(t) over:
% a) 0 to 0.4 sec
% b) 0.4 to 0.6 sec
% c) 0 to 1/6 sec
% d) 0 to 26 sec
clc
clear all
close all
format short
%upper and lower limits of integration
a1=0;
a2=0.4;
b1=0.4;
b2=0.6;
c1=0;
c2=1./6;
d1=0;
d2=26;
%function
fun=@(t)(25+10.*sin(6*t*pi))
fun2=@(t)(25+10.*sin(6*t*pi)).^2
%computation
f_avg_a=(1/(a2-a1)).*(integral(fun,a1,a2))
f_rms_a=sqrt((1/(a2-a1)).*(integral(fun2,a1,a2)))
MATLAB COMMAND WINDOW:
fun =
function_handle with value:
@(t)(25+10.*sin(6*t*pi))
fun2 =
function_handle with value:
@(t)(25+10.*sin(6*t*pi)).^2
f_avg_a =
25.9164
f_rms_a =
26.8118
MY HANDHELD CALCULATOR SHOWS THAT THE ANSWERS SHOULD BE
f_avg_a= 25.657
f_rms_a= 25.6598

Respuestas (1)

the cyclist
the cyclist el 12 de Feb. de 2020
MATLAB's result is correct. You must have made a mistake on your calculator.
You can verify this calculation that I entered into WolframAlpha.
It is also straightforward to carry out this integral with pencil and paper.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by