% script to perform adaptive quadrature
clear all, close all global pts % function to be integrated defined in routine f
f = 'integrand';
a = 1; b = 3;
pts = [a;b]; tol = input('Enter error tolerance: '); % this is just to plot the graph
% it's usually a good idea to look at the integrand
% if possible before you try to integrate it
ezplot(f,[1,3])
disp('Hit any key to continue')
pause
hold on fa = feval(f,a);
fb = feval(f,b); Sf_old = simp(a,b,f,fa,fb); Sf = adaptiveSimpson(a,b,f,fa,fb,tol,Sf_old) qpts = sort(pts);
plot(qpts,zeros(length(pts),1),'rx') disp('number of function evaluations')
disp(length(pts))
disp('Hit any key to continue')
pause % now compare result with straight Simpson's rule
% using the same number of points
sum = 0;
h = (b-a)/(length(pts)-1);
for i=0:length(pts)-1,
fxi = feval(f,a+i*h);
if i == 0 | i == length(pts)-1,
sum = sum + fxi;
elseif mod(i,2) == 1,
sum = sum + 4*fxi;
else
sum = sum + 2*fxi;
end
end
disp('Simpson''s rule with the same number of points')
sum = h/3*sum % compute exact solution
% anti-derivative of integrand is 10*cos(10/x)
% so ...
exactSolution = 10*(cos(10/b)-cos(10/a)); errorAdaptiveSimpson = exactSolution - Sf
errorUniformSimpson = exactSolution - sum

Matlab adaptive quadrature的更多相关文章

  1. Matlab Gauss quadrature

    % matlab script to demonstrate use of Gauss quadrature clear all close all % first derive the 2-poin ...

  2. <<Numerical Analysis>>笔记

    2ed,  by Timothy Sauer DEFINITION 1.3A solution is correct within p decimal places if the error is l ...

  3. <Numerical Analysis>(by Timothy Sauer) Notes

    2ed,  by Timothy Sauer DEFINITION 1.3A solution is correct within p decimal places if the error is l ...

  4. 限制对比度自适应直方图均衡(Contrast Limited Adaptive histgram equalization/CLAHE)

    转自:http://www.cnblogs.com/Imageshop/archive/2013/04/07/3006334.html 一.自适应直方图均衡化(Adaptive histgram eq ...

  5. Matlab小波工具箱的使用2

    Matlab小波工具箱的使用2 (2011-11-11 09:32:57) 转载▼ http://blog.sina.com.cn/s/blog_6163bdeb0102dw7a.html#cmt_5 ...

  6. 数字图像处理的Matlab实现(4)—灰度变换与空间滤波

    第3章 灰度变换与空间滤波(2) 3.3 直方图处理与函数绘图 基于从图像亮度直方图中提取的信息的亮度变换函数,在诸如增强.压缩.分割.描述等方面的图像处理中扮演着基础性的角色.本节的重点在于获取.绘 ...

  7. Paper | Contrast Limited Adaptive Histogram Equalization

    目录 1. 背景 1.1. 对比度和直方图均衡HE 1.2. HE的问题 1.3. AHE 1.4. 底噪问题 2. CLAHE 2.1. 效果展示 2.2. 算法格式和细节 论文:Contrast ...

  8. Gauss-Laguerre quadrature rule

    % matlab script to derive the 2-point Gauss-Laguerre quadrature rule % and use it on an example % in ...

  9. MATLAB数值积分法

    MATLAB数值积分法 作者:凯鲁嘎吉 - 博客园http://www.cnblogs.com/kailugaji/ 一.实验目的 许多工程技术和数学研究中要用到定积分,如果无法直接算不出精确值(如含 ...

随机推荐

  1. GIS中空间数据和非空间数据

  2. 【repost】jQuery笔记总结

    第一节 jQuery初步认知 jQuery概述 JQuery概念 javascript概念 基于Js语言的API和语法组织逻辑,通过内置window和document对象,来操作内存中的DOM元素 J ...

  3. Alpha 冲刺(1)

    Alpha 冲刺 (1/10)   Part.1 开篇 队名:彳艮彳亍团队 组长博客:戳我进入 作业博客:班级博客本次作业的链接 Part.2 成员汇报 组员1(组长)柯奇豪 过去两天完成了哪些任务 ...

  4. ReSharper 10.0.0.2 Ultimate 破解

    文件下载地址:http://pan.baidu.com/s/1gf7l8cF 1.安装ReSharper 10.0.0.2 Ultimate 2.修改Products.json文件的FilePath, ...

  5. 深度学习框架caffe/CNTK/Tensorflow/Theano/Torch的对比

    在单GPU下,所有这些工具集都调用cuDNN,因此只要外层的计算或者内存分配差异不大其性能表现都差不多. Caffe: 1)主流工业级深度学习工具,具有出色的卷积神经网络实现.在计算机视觉领域Caff ...

  6. String、StringBuffer、StringBuild的区别

    他们之间的区别主要在两个重大方面 一.处理速度上 StringBuild > StringBuffer > String 原因: String : 它定义为字符串的常量,定以后不能修改 S ...

  7. python 使用多线程进行并发编程/互斥锁的使用

    import threading import time """ python的thread模块是比较底层的模块,python的threading模块是对thread做了 ...

  8. 跨浏览器的javascript事件的封装

    一,跨浏览器的事件处理程序 1,DOM0级处理事件 将一个函数赋值给一个事件处理程序属性. 事件流:冒泡阶段. 使用: 为元素增加事件: var btn = document.getElementBy ...

  9. Javascript 实现[网红] 时间轮盘

    话不多说,先上图. 成品链接 大致效果如上图,接下来就开始制作吧. HTML部分: 我们需要将容器旋转rotate使之以圆点为中心. 怎么转呢,请看图. 将同一级的容器用一个大的容器包裹起来,绝对定位 ...

  10. 机器学习技法笔记:09 Decision Tree

    Roadmap Decision Tree Hypothesis Decision Tree Algorithm Decision Tree Heuristics in C&RT Decisi ...