?? xintegration.m
字號:
function xIntegration
% 積分例子
% An Example of Integration of a function f(x) from a to b
% by using TRAPZ (trapezoidal numerical integration),
% QUAD (adaptive Simpson quadrature), and QUADL (adaptive Lobatto quadrature)
%
% Author: HUANG Huajiang
% Copyright 2002 UNILAB Research Center,
% East China University of Science and Technology, Shanghai, PRC
% $Revision: 1.0 $ $Date: 2002/05/9 $
clear all
clc
% the interval: [a, b], the step: d
a = 0; % 積分下限
b = 3*pi; % 積分上限
d = pi/1000; % 積分步長
t = a:d:b;
y = func(t);
format long
% 梯形數值積分(Trapezoidal numerical integration)
y_trapz = trapz(y) * d
% 自適應Simpson法(Adaptive Simpson quadrature, low order)
y_quad = quad(@func,a,b)
% 自適應Lobatto求積法(Adaptive Lobatto quadrature, high order)
y_quadl = quadl(@func,a,b)
disp('Results:')
disp(' Trapz Qquad Quadl')
disp([y_trapz,y_quad,y_quadl])
% ------------------------------------------------------------------
function y = func(t)
y = exp(-0.5*t) .* sin(t+pi/6);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -