www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregrbf/cheapwidthopt.m
function [m, cost ,OK] = cheapwidthopt(m,x,y) % use fminsearch to find the optimal single global width using the existing centers and lambda % Copyright 2000-2006 The MathWorks, Inc. and Ford Global Technologies, Inc. wid0 = m.width; if size(wid0,1) == 1 % set up the options fopts= optimset(optimset('fminsearch'),'display','iter'); % Nelder Meade wid= fminsearch(@i_widthsearchcostfn,wid0,fopts,m,x,y); elseif size(wid0,1) > 1 warning(message('mbc:xregrbf:InvalidState1')) cost = getFitOpt(m,'cost'); OK = 0; return end m.width= wid; [m,OK] = leastsq(m,x,y); cost= getFitOpt(m,'cost'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function cost=i_widthsearchcostfn(wid,m,x,y) m.width = wid; % least squares fit [m,OK]= leastsq(m,x,y); cost= getFitOpt(m,'cost'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%