Incorrect numerical integration, how to fix?
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
the cyclist
2020-2-12
MATLAB's result is correct. You must have made a mistake on your calculator.
It is also straightforward to carry out this integral with pencil and paper.
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!