⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 routine.m

📁 等高线拟合源代码(matlab源码)
💻 M
📖 第 1 页 / 共 2 页
字号:
       seterror(' Give new position for marked point.')     end     FILECHANGED = 1;   endelseif strcmp(action,'wijzigpunt'),   p=get(gca,'currentpoint');   x=p(1,1); y = p(1,2);   xl = get(gca,'xlim'); yl = get(gca,'ylim');   % range for pixels from 1 to 128 e.g pixels 64 lies just before the index 64     if ((x >= xl(1)) & (x<= xl(2)) & (y >= yl(1)) & (y <= yl(2))),      x=x-0.5; y=y-0.5;      set(FITHANDLES(3,NUMBER),'string',num2str(x),'value',x);      set(FITHANDLES(4,NUMBER),'string',num2str(y),'value',y);   end   hkruisje = findobj(get(gca,'children'),'marker','x');   l= length(hkruisje);   if l == 0,     % no plotted points found     seterror(' Bug Error: I can''t find ''marker'' = ''x''.');   else      delete(hkruisje);    endelseif strcmp(action,'fit'),   NR_OF_FITS = NR_OF_FITS +1;   val = get(FITHANDLES(1,7),'value');   nrofpoints = get(FITHANDLES(1,12),'value');   if nrofpoints<=1,      seterror(' Nothing to fit through... ')   else       for i = 1:nrofpoints,        xp(i) = get(FITHANDLES(3,i),'value');        yp(i) = get(FITHANDLES(4,i),'value');      end      FILECHANGED = 1;      fit(xp,yp,val);   endelseif strcmp(action,'sort'),   FILECHANGED = 1;   nrofpoints = get(FITHANDLES(1,12),'value');   seterror(' ... sorting list ... ');   for i = 1:nrofpoints,      x(i) = get(FITHANDLES(3,i),'value');      y(i) = get(FITHANDLES(4,i),'value');   end   if strcmp(get(SUBMENUHANDLES(11),'checked'),'on'),     [xs,ind]=sort(x);     ys=y(ind);   else      [ys,ind]=sort(y);      xs=x(ind);   end   if strcmp(get(SUBMENUHANDLES(14),'checked'),'on'),           for i = 1:nrofpoints,       xsd(i)=xs(nrofpoints-i+1);       ysd(i)=ys(nrofpoints-i+1);            end     xs = xsd;     ys=ysd;   end      for i = 1:nrofpoints,      set(FITHANDLES(3,i),'value',xs(i),'string',num2str(xs(i)));      set(FITHANDLES(4,i),'value',ys(i),'string',num2str(ys(i)));   end   seterror(' ... sorting list ... done.');elseif strcmp(action(1:5),'point'),   nrofpoints = get(FITHANDLES(1,12),'value');   nr = str2num(action(6:length(action)));   if strcmp(get(FITHANDLES(1,8),'string'),'Stop Adding'),     % I want to add some points by typing     set(MAINFIG,'Windowbuttondownfcn','',...                 'pointer','arrow');     set(FITHANDLES(1,8),'string','Cancel Typing',...                         'callback','routine(''canceltyping'');routine(''add'')');     set(FITHANDLES(2,nr),'enable','off'),     set(FITHANDLES(3,nr),'style','edit',...                          'callback','routine(''checkvaluesx'')');     NUMBER = nr;     seterror(' Give x- and y-value of point by typing them into the list.');     set(MAINFIG,'currentobject',FITHANDLES(3,nr));   elseif strcmp(get(FITHANDLES(1,8),'string'),'Stop Editing'),     % I want to edit an existing point by typing     set(MAINFIG,'Windowbuttondownfcn','',...                 'pointer','arrow');     set(FITHANDLES(1,8),'string','Cancel Editing',...                         'callback','routine(''canceltyping'');routine(''move'')');     set(FITHANDLES(2,1:nrofpoints),'enable','off'),     set(FITHANDLES(3,nr),'style','edit',...                          'callback','routine(''checkvaluesx'')');     set(FITHANDLES(4,nr),'style','edit',...                          'callback','routine(''checkvaluesy'')');     NUMBER = nr;     seterror(' Change x- or y-value of point by editing into the list.');%     set(MAINFIG,'currentobject',FITHANDLES(3,nr));   else     FILECHANGED = 1;     for i = 1: nr-1,     xc(i) = get(FITHANDLES(3,i),'value');;     yc(i) = get(FITHANDLES(4,i),'value');;     end     for i=nr:nrofpoints-1,           xx = get(FITHANDLES(3,i+1),'value');       yy = get(FITHANDLES(4,i+1),'value');       xc(i) = xx;       yc(i) = yy;       set(FITHANDLES(3,i),'string',num2str(xx),'value',xx);       set(FITHANDLES(4,i),'string',num2str(yy),'value',yy);     end     set(FITHANDLES(3,nrofpoints),'string','','value',-1);     set(FITHANDLES(4,nrofpoints),'string','','value',-1);     set(FITHANDLES(1,12),'value',nrofpoints-1);          if (nrofpoints>1), % there is still at least 1 point left       routine('plotpunten')       seterror(' Point to a previous selected point in the image or press a number in the list to be deleted.');       set(FITHANDLES(1,8), 'string','Stop Deleting');       set(FITHANDLES(2,nrofpoints),'enable','off');     else        hh = findobj(get(gca,'children'),'type','line');        l= length(hh);        while ~(l==0),           delete(hh(1));           hh = findobj(get(gca,'children'),'type','line');           l= length(hh);        end        % Deze while lus is speciaal zo geschreven omdat onder windows        % gemakkelijk meerdere keren dezelfde handle gegeven wordt          if i>length(hh),          seterror(' Error : No type line found ??');          % this should never occur        else          delete(hh(i));        end       FILENAME= '*.mat';       FILECHANGED = 0;       setting('showtitle');       routine('canceldelete');       seterror(' ??? Why didn''t you use ''Clear List'' to delete all the points ??? ');     end   endelseif (strcmp(action,'canceltyping')|strcmp(action,'endtyping')),   hx = FITHANDLES(3,NUMBER);   if get(hx(1),'value') == -1 ,      set(hx(1),'string','',...          'style','text',...          'callback','');   else      set(hx(1),'string',num2str(get(hx(1),'value')),...          'style','text',...          'callback','');   end   hy =FITHANDLES(4,NUMBER);   if get(hy(1),'value') == -1 ,       set(hy(1),'string','',...          'style','text',...          'callback','');   else       set(hy(1),'string',num2str(get(hy(1),'value')),...          'style','text',...          'callback','');   endelseif strcmp(action(1:11),'checkvalues')   nr = NUMBER;   xl = get(gca,'xlim')-0.5;   yl = get(gca,'ylim')-0.5;   x = str2num(get(FITHANDLES(3,nr),'string'));   y = str2num(get(FITHANDLES(4,nr),'string'));   ok = 0;   if strcmp(action(12),'x'),     if (x >= xl(1)) & (x <= xl(2)),       if (y >= yl(1)) & (y <= yl(2)), % x and y values ok !!         ok = 1;       else         % for first time         seterror(' Now, give correct y-value.')         set(FITHANDLES(4,nr),'style','edit',...                            'callback','routine(''checkvaluesy'')');               end     else        seterror(' The given x-value lies outside the actual limits');     end   elseif strcmp(action(12),'y'),     if (y >= yl(1)) & (y <= yl(2)),        % check x again        if (x >= xl(1)) & (x <= xl(2)),  % x and y values ok !!          ok = 1;        else          seterror(' The given x-value lies outside the actual limits');        end     else        seterror(' The given y-value lies outside the actual limits');      end   else     seterror(' Error: This should never occur')   end   if ok,     FILECHANGED = 1;     set(FITHANDLES(3,nr),'value',x);     set(FITHANDLES(4,nr),'value',y);     if strcmp(get(FITHANDLES(1,8),'string'),'Cancel Typing'),       set(FITHANDLES(1,12),'value',nr);       routine('plotpunten');       routine('endtyping');       routine('add');     elseif strcmp(get(FITHANDLES(1,8),'string'),'Cancel Editing'),       % some values has been edited       routine('plotpunten');       routine('endtyping');       routine('move');     else       seterror(' Debug message: This should never occur !');     end   endelse   seterror(' DEBUG ERROR: ... Invalid option in routine.m');end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -