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

📄 browsep.m

📁 matlab算法集 matlab算法集
💻 M
字号:
%----------------------------------------------------------------
% Usage:       browsep
%
% Description: The is the NLIB Problem Browser.  It is designed
%              to simplify the task to running and viewing 
%              solutions to the end of chapter problems.
%----------------------------------------------------------------

% Check Matlab Version

vn = 5.2;
ver = version;
vernum = str2num(ver(1:3));
if vernum < vn
   fprintf ('\nThe NLIB Example Browser requires Matlab Version 5.2');
   fprintf ('\nor later.\n\n');
   return
end

% Read data

clc
clear all

browse_i                   % nlib_probs  solutions to problems
browse_m                   % nlib_module NLIB modules
browse_f                   % nlib_fun    NLIB functions

%----------------------------------------------------------------
% Top Level Menu
%----------------------------------------------------------------

hf_1 = figure('NumberTitle','off','Name',...
'                                           NLIB Problem Browser (MATLAB)');
set (gcf,'Menubar',menubar)

% Full screen

% screen = get (0,'ScreenSize');
% screen(4) = round(0.92*screen(4)); 
% set (gcf,'Position',screen)

% Top Level Menu

hm_1 = uimenu (hf_1,'Label','Run');
hm_2 = uimenu (hf_1,'Label','View');
hm_4 = uimenu (hf_1,'Label','Help');
hm_5 = uimenu (hf_1,'Label','Exit','Callback',...
               'close; clc; return');

%----------------------------------------------------------------
% Run Menu
%----------------------------------------------------------------

% Run Problems 

for i = 1 : 10
   run2(i) = uimenu (hm_1,'Label',sprintf('Chapter %g',i));
end

[m,n] = size (nlib_probs);
num_prob = zeros(10,1);               % number of examples 
for i = 1 : m

   cback = sprintf (...
     'set(gcf,''Visible'',''off''); %s; set(gcf,''Visible'',''on'')',...
      nlib_probs(i,1:8));
   label = deblank(nlib_probs(i,10:n));

% Chapters 1-9

   for j = 1 : 9
      s = sprintf('prob%g',j);
      if (strcmp(nlib_probs(i,1:5),s)) & (nlib_probs(i,6) ~= '0')
         num_prob(j) = num_prob(j) + 1;
         run21(num_prob(j)) = uimenu (run2(j),'Label',label,...
                              'Callback',cback);
      end
   end

% Chapter 10

   if (nlib_probs(i,1:6) == 'prob10')              
      num_prob(10) = num_prob(10) + 1;
      run21(num_prob(10)) = uimenu (run2(10),'Label',label,...
                           'Callback',cback);
   end
end

%----------------------------------------------------------------
% View Menu
%----------------------------------------------------------------

% View Problems 

for i = 1 : 10
   view2(i) = uimenu (hm_2,'Label',sprintf('Chapter %g',i));
end

% Construct callbacks for viewing selected problems

[m,n] = size (nlib_probs);
num_prob = zeros(10,1);               % number of examples 
for i = 1 : m

   q = deblank (nlib_probs(i,1:8));
   cback = sprintf (...
    'set(gcf,''Visible'',''off''); edit %s; set(gcf,''Visible'',''on'')',q);
%...
%      nlib_probs(i,1:8));
   label = deblank(nlib_probs(i,9:n-2));

% Chapters 1-9

   for j = 1 : 9
      s = sprintf('prob%g',j);
      if ((strcmp(nlib_probs(i,1:5),s)) & (nlib_probs(i,6) ~= '0')) | ...
         (strcmp(nlib_probs(i,1:3),'fun') & (nlib_probs(i,5) == s(5))) | ...
         (strcmp(nlib_probs(i,1:5),'data4') & (j == 4)) | ... 
         (nlib_probs(i,n) == s(5))
          num_prob(j) = num_prob(j) + 1;
          view21(num_prob(j)) = uimenu (view2(j),'Label',label,...
                              'Callback',cback);
      end
   end

% Chapter 10

   if ((nlib_probs(i,1:6) == 'prob10') | ...
       (nlib_probs(i,1:6) == 'data10'))               
      num_prob(10) = num_prob(10) + 1;
      view21(num_prob(10)) = uimenu (view2(10),'Label',label,...
                           'Callback',cback);
   end
end

%----------------------------------------------------------------
% Help Menu
%----------------------------------------------------------------

hm_41 = uimenu (hm_4,'Label','NLIB Toolbox Help');

% Toolbox Help

[m,n] = size(nlib_module);
num_fun = zeros(10,1);               % number of functions

for i = 1 : 10
   nhelp(i) = uimenu (hm_41,'Label',sprintf('%s',nlib_module(i,1:n)));
end

[p,q] = size(nlib_fun);

for i = 1 : p

   cback = sprintf (...
     'set(gcf,''Visible'',''off''); more on; clc; help %s; wait; more off; set(gcf,''Visible'',''on'')',...
      nlib_fun(i,4:12));

   label = [nlib_fun(i,4:12) nlib_fun(i,14:q)];

% Chapters 1-9

   for j = 1 : 9
      s = sprintf('%g',j);
      if strcmp(nlib_fun(i,1),s) & ~strcmp(nlib_fun(i,2),'0')
         num_fun(j) = num_fun(j) + 1;
         nhelp11(num_fun(j)) = uimenu (nhelp(j),'Label',label,...
                              'Callback',cback);
         if nlib_fun(i,13) == '.'
            set (nhelp11(num_fun(j)),'Separator','on')
         end
      end
   end

% Chapter 10

   s = '10';
   if strcmp(nlib_fun(i,1:2),s) 
      num_fun(10) = num_fun(10) + 1;
      nhelp11(num_fun(10)) = uimenu (nhelp(10),'Label',label,...
                           'Callback',cback);
      if nlib_fun(i,13) == '.'
         set (nhelp11(num_fun(10)),'Separator','on')
      end
   end

end

% Software Updates

cback = 'set(gcf,''Visible'',''off''); edit browse_s.m; set(gcf,''Visible'',''on'')';

hm_42 = uimenu (hm_4,'Label','NLIB Updates','Separator','on');

hm_421 = uimenu (hm_42,'Label','General information','Callback',cback);

cback1 = 'set(gcf,''Visible'',''off''); web http://sunspot.ece.clarkson.edu/~schillin/nlib; set(gcf,''Visible'',''on'')';

hm_422 = uimenu (hm_42,'Label','Download NLIB updates','Callback',cback1);

% About
           
cback = 'set(gcf,''Visible'',''off''); edit browse_a.m; set(gcf,''Visible'',''on'')';

hm_43 = uimenu (hm_4,'Label','About','Callback',cback,...
        'Separator','on');


⌨️ 快捷键说明

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