Matlab adaptive quadrature
% 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的更多相关文章
- Matlab Gauss quadrature
% matlab script to demonstrate use of Gauss quadrature clear all close all % first derive the 2-poin ...
- <<Numerical Analysis>>笔记
2ed, by Timothy Sauer DEFINITION 1.3A solution is correct within p decimal places if the error is l ...
- <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 ...
- 限制对比度自适应直方图均衡(Contrast Limited Adaptive histgram equalization/CLAHE)
转自:http://www.cnblogs.com/Imageshop/archive/2013/04/07/3006334.html 一.自适应直方图均衡化(Adaptive histgram eq ...
- Matlab小波工具箱的使用2
Matlab小波工具箱的使用2 (2011-11-11 09:32:57) 转载▼ http://blog.sina.com.cn/s/blog_6163bdeb0102dw7a.html#cmt_5 ...
- 数字图像处理的Matlab实现(4)—灰度变换与空间滤波
第3章 灰度变换与空间滤波(2) 3.3 直方图处理与函数绘图 基于从图像亮度直方图中提取的信息的亮度变换函数,在诸如增强.压缩.分割.描述等方面的图像处理中扮演着基础性的角色.本节的重点在于获取.绘 ...
- 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 ...
- Gauss-Laguerre quadrature rule
% matlab script to derive the 2-point Gauss-Laguerre quadrature rule % and use it on an example % in ...
- MATLAB数值积分法
MATLAB数值积分法 作者:凯鲁嘎吉 - 博客园http://www.cnblogs.com/kailugaji/ 一.实验目的 许多工程技术和数学研究中要用到定积分,如果无法直接算不出精确值(如含 ...
随机推荐
- 【转】vim 命令
Vim命令合集 建议直接看原文:(排版有些乱) 命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 vim 直接 ...
- Visual Stuido快捷键
转自:http://www.cnblogs.com/TankXiao/p/3164995.html 整理了一些VS的快捷键 格式化整个文档:(Ctrl + K, Ctrl + D)智能感知:(Ctrl ...
- 音视频编解码——RGB与YUV格式转换
一.RGB模型与YUV模型 1.RGB模型 我们知道物理三基色分别是红(Red).绿(Green).蓝(Blue).现代的显示器技术就是通过组合不同强度的红绿蓝三原色,来达成几乎任何一种可见光的颜色. ...
- Javascript高级编程学习笔记(6)—— 流程控制语句
话不多说,我们直接开始进入今天的主题 流程控制语句 首先什么是流程控制语句呢? 顾名思义,就是控制流程的语句. 在JS中语句定义了ECMAScript中的主要语法,让我们可以使用一系列的关键字来完成指 ...
- web API简介(二):客户端储存之document.cookie API
概述 前篇:web API简介(一):API,Ajax和Fetch 客户端储存从某一方面来说和动态网站差不多.动态网站是用服务端来储存数据,而客户端储存是用客户端来储存数据.document.cook ...
- Spring Boot Runner启动器
Runner启动器 如果你想在Spring Boot启动的时候运行一些特定的代码,你可以实现接口ApplicationRunner或者CommandLineRunner,这两个接口实现方式一样,它们都 ...
- docker 容器时间和系统时间不一致
docker cp /etc/localtime 容器名:/etc/localtime cp /etc/localtime 24fe94504424:/etc/localtime date -s 09 ...
- 使用docker-compose快速构建集群示例(一)
一.zookeeper集群 docker-compose文件: version: '3.1' services: zoo1: image: zookeeper hostname: zoo1 conta ...
- Vim 利剑常磨,见血封喉
年底了,故事总是会有很多. 刚了一波通宵加班,趁着有时间,过了一遍Vim教程,顺便汇总下常用命令. 对于以 OSX / Linux为开发环境的伙伴们,应该并不陌生.因其轻便,扩展性,可定制化,一直很受 ...
- 【原创】贡献一个JS的弹出框代码...
一.前言 最近在做一个项目,自己感觉系统自带的alert()方法的弹出框实在是不堪入目,所以在网上找了一些资料,然后自己加工了一下,做出了自己的一个js弹出框,在这里贡献出来,希望对你有帮助. 二.开 ...