Incorrect numerical integration, how to fix?

1 Ansicht (letzte 30 Tage)
Tanner Sloan
Tanner Sloan am 12 Feb. 2020
Beantwortet: the cyclist am 12 Feb. 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

Antworten (1)

the cyclist
the cyclist am 12 Feb. 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.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by