Matlab interpgui
function interpgui(arg1,arg2)
%INTERPGUI Behavior of interpolating functions.
% Demonstrates interpolation by a piecewise linear interpolant,
% a polynomial, a spline, and a shape preserving Hermite cubic.
% INTERPGUI(x,y) starts with a plot of y vs. x.
% INTERPGUI(y) starts with equally spaced x's.
% INTERPGUI(n) starts with y = zeros(1,n).
% INTERPGUI with no arguments starts with eight zeros.
% The interpolation points can be varied with the mouse.
% If x is specified, it remains fixed.
%
% See also SPLINETX, PCHIPTX, POLYINTERP, PIECELIN. if nargin == 0 | isnumeric(arg1) % Interpret arguments if nargin == 0
% interpgui with no arguments
n = 8;
x = 1:n;
y = zeros(1,n);
elseif length(arg1) == 1
% interpgui(n)
n = arg1;
x = 1:n;
y = zeros(1,n);
elseif nargin == 1
% interpgui(y)
n = length(arg1);
x = 1:n;
y = arg1(:)';
elseif length(arg1) == length(arg2)
% interpgui(x,y)
[x,k] = sort(arg1(:)');
y = arg2(k)';
else
error('Two arguments must have same length')
end
arg1 = []; % Initialize figure shg
clf reset
set(gcf,'doublebuffer','on', ...
'name','Interp gui', 'numbertitle','off', ...
'windowbuttondown',['interpgui(''move''); set(gcf,' ...
'''windowbuttonmotion'',''interpgui(''''move'''')'')'], ...
'windowbuttonup','set(gcf,''windowbuttonmotion'','''')'); % Initialize plots n = length(x);
h = diff(x);
u = zeros(1,128*(n+1));
j = 1:128;
s = (1+sin((j-65)/128*pi))/2;
u(j) = x(1)+(s-1)*h(1);
for k = 1:n-1
u(128*k+j) = x(k)+s*h(k);
end
u(128*n+j) = x(n)+s*h(n-1);
p = plot(x,y,'o',u,zeros(4,length(u)),'-');
ymin = min(y);
ymax = max(y);
ydel = ymax-ymin;
if ydel == 0; ydel = 1; end
axis([min(u) max(u) ymin-0.5*ydel ymax+0.5*ydel])
title('Interpolation') % Controls uicontrol('units','normal','pos',[.68 .13 .12 .18], ...
'style','frame','background','white')
F = {'linear','poly','spline','pchip'};
pos = [.69 .26 .09 .04];
vis = 0;
for k = 1:4
uicontrol('units','normal','pos',pos, ...
'style','check','string',F{k},'value',vis, ...
'background','white','foreground',get(p(k+1),'color'), ...
'callback','interpgui(''cb'')');
pos(2) = pos(2)-.04;
end
uicontrol('units','normal','pos',[.85 .01 .10 .06], ...
'style','push','string','close','tag','reset/close', ...
'callback','close(gcf)'); % Remember original data xfree = (nargin < 2);
set(gcf,'userdata',xfree)
set(gca,'userdata',{x,y})
end p = flipud(get(gca,'children'));
x = get(p(1),'xdata');
y = get(p(1),'ydata');
n = length(x);
h = diff(x);
u = zeros(1,128*(n+1));
j = 1:128;
s = (1+sin((j-65)/128*pi))/2;
u(j) = x(1)+(s-1)*h(1);
for k = 1:n-1
u(128*k+j) = x(k)+s*h(k);
end
u(128*n+j) = x(n)+s*h(n-1); if isequal(arg1,'reset') % Restore original data xy = get(gca,'userdata');
x = xy{1};
y = xy{2};
set(findobj('tag','reset/close'),'string','close', ...
'callback','close(gcf)'); elseif isequal(arg1,'move') % Respond to mouse motion z = get(gca,'currentpoint');
z = z(1,:);
p = flipud(get(gca,'children'));
e = abs(x-z(1));
k = min(find(e == min(e)));
xfree = get(gcf,'userdata');
if xfree
x(k) = z(1);
end
y(k) = z(2);
set(findobj('tag','reset/close'),'string','reset', ...
'callback','interpgui(''reset'')'); end ax = axis;
set(p(1),'xdata',x,'ydata',y)
set(p(2),'xdata',u,'ydata',piecelin(x,y,u));
set(p(3),'xdata',u,'ydata',polyinterp(x,y,u));
set(p(4),'xdata',u,'ydata',splinetx(x,y,u));
set(p(5),'xdata',u,'ydata',pchiptx(x,y,u));
axis(ax); % Visibility b = flipud(get(gcf,'children'));
onf = {'off','on'};
for k = 1:4
% Interpolants
set(p(k+1),'visible',onf{get(b(k+2),'value')+1})
end
Matlab interpgui的更多相关文章
- Matlab 绘制三维立体图(以地质异常体为例)
前言:在地球物理勘探,流体空间分布等多种场景中,定位空间点P(x,y,x)的物理属性值Q,并绘制三维空间分布图,对我们洞察空间场景有十分重要的意义. 1. 三维立体图的基本要件: 全空间网格化 网格节 ...
- Matlab slice方法和包络法绘制三维立体图
前言:在地球物理勘探,流体空间分布等多种场景中,定位空间点P(x,y,x)的物理属性值Q,并绘制三维空间分布图,对我们洞察空间场景有十分重要的意义. 1. 三维立体图的基本要件: 全空间网格化 网格节 ...
- Matlab 高斯_拉普拉斯滤波器处理医学图像
前言:本程序是我去年实现论文算法时所做.主要功能为标记切割肝脏区域.时间有点久,很多细节已经模糊加上代码做了很多注释,因此在博客中不再详述. NOTE: 程序分几大段功能模块,仔细阅读,对解决医学图像 ...
- MATLAB中绘制质点轨迹动图并保存成GIF
工作需要在MATLAB中绘制质点轨迹并保存成GIF以便展示. 绘制质点轨迹动图可用comet和comet3命令,使用例子如下: t = 0:.01:2*pi;x = cos(2*t).*(cos(t) ...
- linux下配置matlab运行环境(MCR)
在安装好的matlab下有MCR(MatlabCompilerRuntime)在matlab2011/toolbox/compiler/deploy/glnxa64下找到MCRInstaller.zi ...
- EMD分析 Matlab 精华总结 附开源工具箱(全)
前言: 本贴写于2016年12与15日,UK.最近在学习EMD(Empirical Mode Decomposition)和HHT(Hilbert-Huang Transform)多分辨信号处理,FQ ...
- Atitit MATLAB 图像处理 经典书籍attilax总结
Atitit MATLAB 图像处理 经典书籍attilax总结 1.1. MATLAB数字图像处理1 1.2. <MATLAB实用教程(第二版)>((美)穆尔 著)[简介_书评_在线阅读 ...
- Atitit MATLAB 图像处理attilax总结
Atitit MATLAB 图像处理attilax总结 1.1. 下载 Matlab7.0官方下载_Matlab2012 v7.0 官方简体中文版-办公软件-系统大全.html1 1.2. Matla ...
- Atitit java c# php c++ js跨语言调用matlab实现边缘检测等功能attilax总结
Atitit java c# php c++ js跨语言调用matlab实现边缘检测等功能attilax总结 1.1. 边缘检测的基本方法Canny最常用了1 1.2. 编写matlab边缘检测代码, ...
随机推荐
- [BZOJ3676][APIO2014]回文串(Manacher+SAM)
3676: [Apio2014]回文串 Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 3097 Solved: 1408[Submit][Statu ...
- Codeforces Beta Round #4 (Div. 2 Only) A. Watermelon 水题
A. Watermelon 题目连接: http://www.codeforces.com/contest/4/problem/A Description One hot summer day Pet ...
- .apk文件的MIME类型
IIS7中下载apk文件会报404错误. 找到:IIS目录,MIME类型 添加.apk文件的MIME类型. 文件扩展名:.apk MIME类型:application/vnd.android.pack ...
- OpenWrt包管理软件opkg的使用(极路由)
说明: 1.OpenWrt本身系统没什么问题,关键点是一些路由器尝试的限制,比如一些厂商设置成内存分区为只读,那么这个安装软件就变得没什么意义了. 2.opkg的操作有点反人类,正常步骤是查询,安装: ...
- 用Java实现HTTP Multipart的服务端和客户端
今天简单介绍一下如何用Java支持HTTP Multipart的request和response. 整个项目的代码可以在https://github.com/mcai4gl2/multi下载. 在这个 ...
- IDA Pro plug-in defines
/* This file contains definitions used by the Hex-Rays decompiler output. It has type definitions an ...
- Spring @PostConstruct和@PreDestroy实例
在Spring中,既可以实现InitializingBean和DisposableBean接口或在bean配置文件中指定 init-method 和 destroy-method 在初始化和销毁回调函 ...
- jdbc框架有很多,包括spring jdbc
1.由于jdbc连接的繁琐性,故很多公司封装了jdbc框架,比如spring jdbc 2.比如spring jdbc框架中,用jdbctemplate, 通过jdbcTemplate 提供 int ...
- appium+python自动化60-windows上同时启动多个appium服务,让多个android机器并行运行
前言 做android自动化的时候,启动一个appium服务,只能匹配一个手机去自动化执行.有时候想同一套代码,可以在不同的手机上执行,测下app在不同手机上兼容性. 这就需要启动多个appium服务 ...
- Python学习(四)数据结构 —— list tuple range
序列类型 list tuple range list 和 tuple list: 列表,由 [] 标识: 有序:可改变列表元素 tuple: 元组,由 () 标识: 有序:不可改变元组元素(和 ...