1. % script to perform adaptive quadrature
  2. clear all, close all
  3.  
  4. global pts
  5.  
  6. % function to be integrated defined in routine f
  7. f = 'integrand';
  8. a = 1; b = 3;
  9. pts = [a;b];
  10.  
  11. tol = input('Enter error tolerance: ');
  12.  
  13. % this is just to plot the graph
  14. % it's usually a good idea to look at the integrand
  15. % if possible before you try to integrate it
  16. ezplot(f,[1,3])
  17. disp('Hit any key to continue')
  18. pause
  19. hold on
  20.  
  21. fa = feval(f,a);
  22. fb = feval(f,b);
  23.  
  24. Sf_old = simp(a,b,f,fa,fb);
  25.  
  26. Sf = adaptiveSimpson(a,b,f,fa,fb,tol,Sf_old)
  27.  
  28. qpts = sort(pts);
  29. plot(qpts,zeros(length(pts),1),'rx')
  30.  
  31. disp('number of function evaluations')
  32. disp(length(pts))
  33. disp('Hit any key to continue')
  34. pause
  35.  
  36. % now compare result with straight Simpson's rule
  37. % using the same number of points
  38. sum = 0;
  39. h = (b-a)/(length(pts)-1);
  40. for i=0:length(pts)-1,
  41. fxi = feval(f,a+i*h);
  42. if i == 0 | i == length(pts)-1,
  43. sum = sum + fxi;
  44. elseif mod(i,2) == 1,
  45. sum = sum + 4*fxi;
  46. else
  47. sum = sum + 2*fxi;
  48. end
  49. end
  50. disp('Simpson''s rule with the same number of points')
  51. sum = h/3*sum
  52.  
  53. % compute exact solution
  54. % anti-derivative of integrand is 10*cos(10/x)
  55. % so ...
  56. exactSolution = 10*(cos(10/b)-cos(10/a));
  57.  
  58. errorAdaptiveSimpson = exactSolution - Sf
  59. 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. DL_1_week1_概论

    standard NN,CNN,RNN,custom hybrid NN architecture(Radar) 结构化数据是数据的数据库,相比结构化数据计算机更难理解非结构化数据,人生来很容易理解非 ...

  2. javabean的特点

    javabean的三个基础条件 1.拥有私有的属性 2.共有的get,set方法 3.默认的构造方法

  3. 基于dsp_builder的算法在FPGA上的实现(转自https://www.cnblogs.com/sunev/archive/2012/11/17/2774836.html)

    一.摘要 结合dsp_builder.matlab.modelsim和quartus ii等软件完成算法的FPGA实现. 二.实验平台 硬件平台:DIY_DE2 软件平台:quartus ii9.0 ...

  4. @WebFilter怎么控制多个filter的执行顺序

    转自:http://blog.csdn.net/liming_0820/article/details/53332070 之前我们控制多个filter的执行顺序是通过web.xml中控制filter的 ...

  5. 关于调试WCF时引发的异常XmlException: Name cannot begin with the '<' character, hexadecimal value 0x3C” on Client Side

    问题描述:在使用VS2015调试WCF时,偶遇抛出异常名称不能以“<”字符(十六进制0x3c)开头,平时运行时(不调试)没有问题的. 解决方法:检查后发现为了检查异常的位置,勾选了引发通用语言运 ...

  6. Container Adaptors

    Notes from C++ Primer stack and queue: based on deque priority_queue:    based on vector Standard li ...

  7. Eclipse 中 SVN 插件的安装与使用

    下载和安装SVN插件 插件在线安装 可以选择在线安装插件的方式,就是使用eclipse里Help菜单的“Install New Software”,通过输入SVN地址,直接下载安装到eclipse里. ...

  8. process(进程)

    进程 指的是执行中程序的一个实例(instance). 新进程由fork() 与 execve() 等系统调用起始,然后执行,直到下达exit()系统调用为止. 操作系统内核里,称为调度器(sched ...

  9. Restore database use sql `*.bak` file

    1.第一步: 2.第二步: 3.第三布: 4.第四步:

  10. vue-cli3 DllPlugin 提取公用库

    vue 开发过程中,保存一次就会编译一次,如果能够减少编译的时间,哪怕是一丁点,也能节省不少时间.开发过程中个人编写的源文件才会频繁变动,而一些库文件我们一般是不会去改动的.如果能把这些库文件提取出来 ...