How to do Numerical Integration of excel data using gauss quadrant?

조회 수: 1 (최근 30일)
Hello all,
I am trying to do a numerical integration of a excel data using gauss quadrant method. I have a function Q = f(Y) which is Q = A*Y, Whre Y is the data from excel at different X positions. I have tried using gauss_quad function. But I am getting an error in it. How can i get the integral value at every location along with a curve of the integral data? Please kindly help me.
My code:
function [I]=Gauss_quad(fstr,a,b)
if nargin<1,
help Gauss.m;
v = xlsread('flow.xlsx','B:B');
r = 0.0685;
A = pi*r^2;
fstr='A*Y';
a=0.01; b=1.5;
end
f=vectorize(inline(fstr,0));
% Seven-point integration scheme so zeta_1 to zeta_7
zeta=[-0.9491079123; -0.7415311855; -0.4058451513; 0.0;
0.4058451513; 0.7415311855; 0.9491079123];
% Weighting coefficients
w=[0.1294849661; 0.2797053914; 0.3818300505; 0.4179591836;
0.3818300505; 0.2797053914; 0.1294849661];
% Index for the seven points
Index=1:7;
% Gauss Integration
I=(b-a)/2*sum(w(Index).*f((b-a).*(zeta(Index)+1)/2+a));
% Display the result
disp(' '); disp(strcat('The integral = ', num2str(I)));

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by