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

📄 nnident.m

📁 神经网络预测控制程序的源代码
💻 M
📖 第 1 页 / 共 5 页
字号:
function nnident(cmd,arg1,arg2,arg3)
%NNIDENT Neural Network Identification GUI for Neural Network Controller Toolbox.
%
%  Synopsis
%
%    nnident(cmd,arg1,arg2,arg3)
%
%  Warning!!
%
%    This function may be altered or removed in future
%    releases of the Neural Network Toolbox. We recommend
%    you do not write code which calls this function.
%    This function is generally being called from a Simulink block.

% Orlando De Jesus, Martin Hagan, 1-25-00
% Copyright 1992-2002 The MathWorks, Inc.
% $Revision: 1.7 $ $Date: 2002/04/14 21:11:10 $

% Orlando De Jesus. Strict generation of random signals for training. 
% Final plots after training (Target and NN) have the same axis to easier comparative results.

% CONSTANTS
func_index=['trainbfg';'trainbr ';'traincgb';'traincgf';'traincgp';'traingd ';'traingdm';'traingda';'traingdx';'trainlm ';'trainoss';'trainrp ';'trainscg'];

% DEFAULTS
if nargin == 0, cmd = ''; else cmd = lower(cmd); end

% FIND WINDOW IF IT EXISTS
fig = 0;

% 9/3/99 We alow the program to see hidden handles
fig=findall(0,'type','figure','tag','nnident');
if (size(fig,1)==0), fig=0; end

if (length(get(fig,'children')) == 0), fig = 0; end

% GET WINDOW DATA IF IT EXISTS
if fig
  H = get(fig,'userdata');
  
  if strcmp(cmd,'')
    if get(H.gcbh_ptr,'userdata')~=arg1
      delete(fig);
      fig=0;
    end
  else
    % ODJ 1-13-00 We check if the field SimulationStatus exist before reading that field
    if isfield(get(H.gcbh_ptr,'userdata'))
       if isfield(get_param(get_param(get(H.gcbh_ptr,'userdata'),'parent'),'objectparameters'),'SimulationStatus')
          SimulationStatus=get_param(get_param(get(H.gcbh_ptr,'userdata'),'parent'),'simulationstatus');
       else
          SimulationStatus='none';
       end
    else
       SimulationStatus='none';
    end
       
    if (strcmp(SimulationStatus,'running') | strcmp(SimulationStatus,'paused')) & ~strcmp(cmd,'close')
      set(H.error_messages,'string','You must stop the simulation to change NN configuration parameters.');
      return;
    end
  end

end

%==================================================================
% Activate the window.
%
% ME() or ME('')
%==================================================================

if strcmp(cmd,'') | isempty(cmd)
  if fig
    figure(fig)
    set(fig,'visible','on')
  else
    nncontrolutil('nnident','init',arg1,arg2,arg3)
  end

%==================================================================
% Close the window.
%
% ME() or ME('')
%==================================================================

elseif strcmp(cmd,'close') & (fig)
   arg1=get(H.gcbh_ptr,'userdata');
   arg2=get(H.gcb_ptr,'userdata');
   if exist(cat(2,tempdir,'nnidentdata.mat'))
      delete(cat(2,tempdir,'nnidentdata.mat'));
   end
   parent_function=get(H.parent_function_ptr,'userdata');
   if ~strcmp(parent_function,'narma_l2')
      feval(parent_function,'',arg1,arg2,'nnident');
   end
   delete(fig);
%   nnmodref('',arg1,arg2);
  
%==================================================================
% Initialize the window.
%
% ME('init')
%==================================================================

elseif strcmp(cmd,'init') & (~fig)
    
  % 1-13-00 ODJ We check if the system is locked.
  sys_par=arg2;
  sys_par2=arg2;
  while ~isempty(sys_par2)
      sys_par=sys_par2;
      sys_par2=get_param(sys_par,'parent');
  end
  if strcmp('on',get_param(sys_par,'lock'))
      window_en='off';
  else
      window_en='on';
  end

  H.StdColor = get(0,'DefaultUicontrolBackgroundColor');
  H.StdUnit='points';
  H.PointsToPixels = 72/get(0,'ScreenPixelsPerInch');

  if strcmp(arg3,'narma_l2')
     H.me='Plant Identification - NARMA-L2';
  else
     H.me = 'Plant Identification';
  end
  fig = figure('Units',H.StdUnit, ...
  'Color',[0.8 0.8 0.8], ...
   'IntegerHandle',  'off',...
   'Interruptible','off', ...
   'BusyAction','cancel', ...
   'HandleVis','Callback', ...
  'MenuBar','none', ...
   'Name',H.me, ...
   'Numbertitle','off', ...
  'PaperUnits',H.StdUnit, ...
  'Position',[45 30 350 358], ...
  'Tag','nnident', ...
  'ToolBar','none');
  frame4 = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
  'ListboxTop',0, ...
  'Position',[5 2 340 22], ...
  'Style','frame', ...
  'Tag','Frame4');
  frame5 = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
  'ListboxTop',0, ...
  'Position',[5 26 340 67], ...
  'Style','frame', ...
  'Tag','Frame5');
  h1 = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[130 83.5 90.25 15], ...
  'String','Training Parameters', ...
  'Style','text', ...
  'Tag','StaticText1');
  frame1 = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
  'ListboxTop',0, ...
  'Position',[5 103 340 137], ...
  'Style','frame', ...
  'Tag','Frame1');
  h1 = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[140 229.75 70.25 15], ...
  'String','Training Data', ...
  'Style','text', ...
  'Tag','StaticText1');
  frame6 = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
  'ListboxTop',0, ...
  'Position',[5 248 340 73], ...
  'Style','frame', ...
  'Tag','Frame6');
  h1 = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[130 310.75 90.25 15], ...
  'String','Network Architecture', ...
  'Style','text', ...
  'Tag','StaticText1');
  H.Title_nnident = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
  'FontSize',14, ...
  'ListboxTop',0, ...
  'Position',[24.75 330 298.5 21.75], ...
  'String',H.me, ...
  'Style','text', ...
   'Tag','Title_nnident');
  H.Hidden_layer_size = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[1 1 1], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[125 296 45 15], ...
  'Style','edit', ...
   'ToolTipStr','Defines the size of the second layer of the neural network plant model.',...
  'Tag','Hidden_layer');
  H.Hidden_layer_text = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
    'HorizontalAlignment','right', ...
  'ListboxTop',0, ...
  'Position',[10 296 110 15], ...
  'String','Size of Hidden Layer', ...
  'Style','text', ...
   'ToolTipStr','Defines the size of the second layer of the neural network plant model.',...
  'Tag','StaticText1');
  H.simulink_file_text = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[170 151 110 15], ...
  'String','Simulink Plant Model:', ...
  'Style','text', ...
   'ToolTipStr','Simulink file containing the plant to be modeled.',...
  'Tag','StaticText1');
  H.BrowseButton = uicontrol('Parent',fig, ...
  'Unit',H.StdUnit, ...
  'Callback','nncontrolutil(''nnident'',''browsesim'',gcbf);', ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[285 151 45 16], ...
  'String','Browse', ...
   'ToolTipStr','Allow the user to select a Simulink file.',...
  'Tag','BrowseButton');
  H.simulink_file = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[1 1 1], ...
    'Enable',window_en, ...
  'Callback','nncontrolutil(''nnident'',''clearpath'',gcbf);', ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[185 129 145 15], ...
  'Style','edit', ...
   'ToolTipStr','Simulink file containing the plant to be modeled.',...
  'Tag','Plant_model');
  H.Sampling_text = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
   'HorizontalAlignment','right', ...
  'ListboxTop',0, ...
  'Position',[10 275 110 15], ...
  'String','Sampling Interval (sec)', ...
  'Style','text', ...
   'ToolTipStr','Sampling interval at which the data will be collected from the Simulink plant model.',...
  'Tag','StaticText1');
  H.Sampling_time = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[1 1 1], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[125 275 45 15], ...
  'Style','edit', ...
   'ToolTipStr','Sampling interval at which the data will be collected from the Simulink plant model.',...
  'Tag','Sampling_time');
  H.Delayed_input_text = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
   'HorizontalAlignment','right', ...
  'ListboxTop',0, ...
  'Position',[170 296 110 15], ...
  'String','No. Delayed Plant Inputs', ...
  'Style','text', ...
   'ToolTipStr','Defines how many delays on the plant input will be used to feed the neural network plant model.',...
  'Tag','StaticText1');
  H.Delayed_input = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[1 1 1], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Max',500, ...
  'Min',1, ...
  'Position',[285 296 45 15], ...
  'Style','edit', ...
  'Tag','Ni', ...
   'ToolTipStr','Defines how many delays on the plant input will be used to feed the neural network plant model.',...
  'Value',1);
  H.Delayed_output_text = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
   'HorizontalAlignment','right', ...
  'ListboxTop',0, ...
  'Position',[170 274 110 15], ...
  'String','No. Delayed Plant Outputs', ...
  'Style','text', ...
   'ToolTipStr','Defines how many delays on the plant output will be used to feed the neural network plant model.',...
  'Tag','StaticText1');
  H.Delayed_output = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[1 1 1], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Max',500, ...
  'Min',1, ...
  'Position',[285 274 45 15], ...
  'Style','edit', ...
  'Tag','Nj', ...
   'ToolTipStr','Defines how many delays on the plant output will be used to feed the neural network plant model.',...
  'Value',1);
  H.Limit_output_data = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
  'Callback','nncontrolutil(''nnident'',''limit_output'')', ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[200 217 110 15], ...
  'String','Limit Output Data', ...
  'Style','checkbox', ...
  'Tag','checkbox3', ...
   'ToolTipStr','If selected, the plant output data will be bounded.',...
  'Value',1);
  H.Normalize_data = uicontrol('Parent',fig, ...
  'Units',H.StdUnit, ...
  'BackgroundColor',[0.8 0.8 0.8], ...
    'Enable',window_en, ...
  'ListboxTop',0, ...
  'Position',[20 253 110 15], ...
  'String','Normalize Training Data', ...
  'Style','checkbox', ...
  'Tag','checkbox2', ...
   'ToolTipStr','If selected, the plant input-output data will be normalized.',...

⌨️ 快捷键说明

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