function splinetool(x,y)
%SPLINETOOL Experiment with some spline approximation methods (GUI).
%
% SPLINETOOL prompts you for some data sites and data values to fit and
% lets you do this in various ways.
% One of the choices is to provide your own data, in which case both
% the sites and values can be expressions that evaluate to vectors required
% to be of the same length.
% You can also specify the values by providing the name of a function whose
% values at the sites are to be used as data values.
% You can also provide the name of a function (like 'titanium') whose
% two-argument output provides numerical values for sites and values.
% In any case, there must be at least two distinct sites.
% The other choices provide specific sample sites and values to illustrate
% various aspects of the GUI.
%
% SPLINETOOL(X,Y) uses the input data sites X and data values Y, and these
% must be numerical vectors of the same length > 1. The data sites need not
% be distinct nor ordered, but there must be at least two distinct sites.
%
% Example:
% x = linspace(1,pi,101); y = cos(x)+(rand(size(x))-.5)/10;
% splinetool(x,y)
% might start an interesting experimentation with noisy data.
%
% See also CSAPI, CSAPS, SPAPS, SPAP2, SPAPI.
% Copyright 1987-2010 The MathWorks, Inc.
% $Revision: 1.1.6.3.2.1 $ $Date: 2010/06/28 14:16:57 $
testing = 0;
v = ver('curvefit');
[relYear,~,~] = datevec(v.Date);
abouttext = {
sprintf( '%s %s', v.Name, v.Version )
sprintf( 'Copyright 1987-%d The MathWorks, Inc.', relYear )
};
if nargin<1 % import data
action = 'start';
else
if ischar(x)
action = x;
hand = get(gcbf,'Userdata');
if isstruct(hand)&&isfield(hand,'currentline')
hc = hand.currentline; % make available, for use with changes
end
else % check and sort the given data
[x,y] = chckxy(x,y);
xname = 'x'; yname = 'y';
isf = 0;
action = 'start';
end
end
switch action
case 'add_item' % add an item
switch get(hand.data_etc,'Value')
case 1
[xx,yy] = ask_for_add(hand);
x = get(hand.dataline,'Xdata');
if xx<x(1)||xx>x(end)
warndlg(['The Spline Tool will let you only', ...
' add interior data sites.'], ...
'Attempted change of interval of approximation','modal')
elseif get(hand.method,'Value')==4 && any(x==xx)
warndlg(['Since SPAPI would interpret repeated data sites',...
' as a request for osculatory interpolation, the Spline Tool',...
' won''t let you create repeated data sites now.'], ...
'Repeated data sites', 'modal');
else
set(hand.undo,'Enable','on')
insert_and_mark(x,get(hand.dataline,'Ydata'),xx,yy,hand)
undoud = get(hand.undo,'Userdata');
undoud.lineud = get(hand.nameline,'Userdata');
set(hand.undo,'Userdata',undoud);
get_approx(hand)
end
if isequal(get(hand.undo,'Enable'),'off')
V = get(hand.params(1,3),'Value');
set(hand.params(2,3),'String',x(V))
if isequal(get(hand.params(2,5),'Visible'),'on')
y = get(hand.dataline,'Ydata');
set(hand.params(2,5),'String',y(V))
end
end
case 2
switch get(hand.method,'Value')
case 3
xx = ask_for_add(hand);
lineud = get(hand.nameline,'Userdata');
[lineud.knots,i] = sort([lineud.knots,xx]);
placed = find(i==length(lineud.knots));
if placed==1||placed==length(lineud.knots)
warndlg('The Spline Tool will only let you add interior knots.',...
'The end knots are forever','modal')
lineud.knots(placed)=[];
set(hand.nameline,'Userdata',lineud)
set(hand.params(2,4),'String', ...
lineud.knots(get(hand.params(1,4),'Value')))
else
set(hand.params(1,4),'String',lineud.knots(:),'Value', placed)
lineud = update(hand,'knots',lineud);
lineud.kc(end+1) = ...
addchange(hc,['knots = sort([knots,',num2str(xx,15),']);',...
' %% you added a knot']);
set(hand.nameline,'Userdata',lineud)
% update knots display
set(hand.buttonm,'Visible','on')
set(hand.params(4,4), 'String',...
(lineud.knots(end)-lineud.knots(1))/(10*length(lineud.knots)))
markb(hand), set_bdisplay(lineud.knots,hand)
get_approx(hand)
end
end %switch get(hand.method,'Value')
case 3
end %switch get(hand.data_etc,'Value')
case 'align' % make sure the left and right data list are aligned
% at present, this serves no function, but sits here in case clicking
% anywhere on a list box activates a callback
tag = get(gcbo,'Tag');
if tag(5)=='l', j=3; else j=5; end
set(hand.params(1,8-j),'Value',get(hand.params(1,j),'Value'))
case 'axesclick' % action when the axes is clicked
% protect against clicks on Print Figure window:
if isempty(hand), return, end
% only react here to LEFT clicks
tmp = get(hand.figure,'SelectionType');
if tmp(1)=='n'
% get the location of the latest click in data coordinates:
clickp = get(hand.Axes(1),'CurrentPoint');
switch get(hand.data_etc,'Value')
case {1,3} % highlight the nearest data point
highlightn(clickp,hand)
case 2
switch get(hand.method,'Value')
case {1,3,4}
% find the nearest break
breaks = str2num(get(hand.params(1,4),'String')); %#ok<ST2NM> breaks is a vector
[~,V]=min(abs(breaks(:)-repmat(clickp(1),length(breaks),1)));
if get(hand.params(1,4),'Value')~=V
set(hand.params(1,4),'Value',V), markb(hand)
end
case 2
highlightn(clickp,hand)
end %switch get(hand.method,'Value')
end %switch get(hand.data_etc,'Value')
end %if tmp(1)=='n'
case 'change_name' % change the name of the current spline
names = get_names(get(hand.list_names,'String'));
V = get(hand.list_names,'Value');
oldname = names(V,:); oldname = deblank(oldname(6:end));
name = '';
while isempty(name)
answer = inputdlg(...
'Give a (valid MATLAB variable) name for the current spline:',...
'Please provide a new name for the current spline ...', 1,...
{oldname});
if isempty(answer)||strcmp(answer{:},oldname), return, end
name = full_name(answ
没有合适的资源?快使用搜索试试~ 我知道了~
spline toolbox
共151个文件
m:150个
mat:1个
5星 · 超过95%的资源 需积分: 40 44 下载量 34 浏览量
2017-08-22
14:18:21
上传
评论 2
收藏 238KB RAR 举报
温馨提示
在学习B样条曲线的时候总是找各种实现样条曲线的方法,参考了OpenGL,还有论坛里用QT实现的方式,在查matlab的实现方式的时候总是找不到这个工具包,无奈只能下载完整的matlab了。这里上传这个工具箱给大家备用
资源推荐
资源详情
资源评论
收起资源包目录
spline toolbox (151个子文件)
splinetool.m 166KB
fncmb.m 20KB
spaps.m 19KB
spterms.m 17KB
fnzeros.m 14KB
rscvn.m 12KB
csaps.m 11KB
spcol.m 11KB
rsmak.m 10KB
csape.m 10KB
chckxywp.m 9KB
fn2fm.m 9KB
pp2sp.m 8KB
fntlr.m 8KB
ppbrk.m 8KB
tpaps.m 8KB
ppmak.m 7KB
fnplt.m 7KB
spap2.m 7KB
spapi.m 7KB
csaps.m 7KB
fnbrk.m 6KB
spbrk.m 6KB
ppual.m 6KB
sprfn.m 6KB
fnxtr.m 5KB
fnder.m 5KB
spaps.m 5KB
csape.m 5KB
chbpnt.m 5KB
csapi.m 5KB
pprfn.m 4KB
Contents.m 4KB
spval.m 4KB
spmak.m 4KB
stmak.m 4KB
spapi.m 4KB
fndir.m 4KB
stbrk.m 4KB
fnval.m 4KB
slvblk.m 4KB
fnint.m 3KB
newknt.m 3KB
spap2.m 3KB
rsmak.m 3KB
stcol.m 3KB
rpbrk.m 3KB
fnbrk.m 3KB
rsbrk.m 3KB
aptknt.m 3KB
fnjmp.m 3KB
ppmak.m 3KB
tpaps.m 3KB
spcol.m 3KB
Contents.m 3KB
cscvn.m 3KB
chckxywp.m 3KB
rscvn.m 2KB
fnrfn.m 2KB
optknt.m 2KB
sp2pp.m 2KB
fnval.m 2KB
bkbrk.m 2KB
fnmin.m 2KB
spcrv.m 2KB
augknt.m 2KB
fncmb.m 2KB
fn2fm.m 2KB
stmak.m 2KB
fnxtr.m 2KB
fntlr.m 2KB
rsval.m 2KB
rpmak.m 2KB
stval.m 2KB
fnrfn.m 2KB
bspline.m 2KB
splpp.m 2KB
pp2sp.m 2KB
spmak.m 2KB
csapi.m 2KB
fndir.m 2KB
stcol.m 1KB
ppbrk.m 1KB
brk2knt.m 1KB
fnchg.m 1KB
getcurve.m 1KB
sp2bb.m 1KB
fnplt.m 1KB
splinetool.m 1KB
slvblk.m 1KB
augknt.m 1KB
sprpp.m 1KB
spterms.m 1KB
aptknt.m 1KB
rpmak.m 1KB
rpbrk.m 1KB
aveknt.m 1KB
fnder.m 1010B
chbpnt.m 981B
sorted.m 973B
共 151 条
- 1
- 2
资源评论
- zhouweibin20122018-05-17非常好,终于找到了
- weixin_433885262018-11-07请问下载后如何安装
- 赌ml2018-04-13找了很久,感谢分享
二两元年
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功