Incorrect numerical integration, how to fix?

조회 수: 2 (최근 30일)
Tanner Sloan
Tanner Sloan 2020년 2월 12일
답변: the cyclist 2020년 2월 12일
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

답변 (1개)

the cyclist
the cyclist 2020년 2월 12일
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.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by