📄 nnmodref.m
字号:
'Enable',window_en, ...
'ListboxTop',0, ...
'Max',500, ...
'Min',1, ...
'Position',[290 274 45 15], ...
'Style','edit', ...
'Tag','Nr', ...
'ToolTipStr','Defines how many delays on the reference input will be used to feed the controller.',...
'Value',1);
H.Delayed_contr_output_text = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable',window_en, ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',[175 252 110 15], ...
'String','No. Delayed Controller Outputs', ...
'Style','text', ...
'ToolTipStr','Defines how many delays on the controller 0utput (same as plant input) will be used to feed the controller.',...
'Tag','StaticText1');
H.Delayed_contr_output = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable',window_en, ...
'ListboxTop',0, ...
'Max',500, ...
'Min',1, ...
'Position',[290 252 45 15], ...
'Style','edit', ...
'Tag','Ni', ...
'ToolTipStr','Defines how many delays on the controller output (same as plant input) will be used to feed the controller.',...
'Value',1);
H.Delayed_output_text = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable',window_en, ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',[175 230 110 15], ...
'String','No. Delayed Plant Outputs', ...
'Style','text', ...
'ToolTipStr','Defines how many delays on the plant output will be used to feed the controller.',...
'Tag','StaticText1');
H.Delayed_output = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable',window_en, ...
'ListboxTop',0, ...
'Max',500, ...
'Min',1, ...
'Position',[290 230 45 15], ...
'Style','edit', ...
'Tag','Nj', ...
'ToolTipStr','Defines how many delays on the plant output will be used to feed the controller.',...
'Value',1);
H.sam_training_c_edit = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[1 1 1], ...
'Enable',window_en, ...
'ListboxTop',0, ...
'Position',[290 195 45 15], ...
'Style','edit', ...
'ToolTipStr','Defines how many data points will be generated for training.',...
'Tag','sam_training_c_edit');
H.sam_training_c_text = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable',window_en, ...
'HorizontalAlignment','right', ...
'ListboxTop',0, ...
'Position',[175 195 110 15], ...
'String','Controller Training Samples', ...
'Style','text', ...
'ToolTipStr','Defines how many data points will be generated for training.',...
'Tag','StaticText2');
H.Use_Previous_Weights_but = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable',window_en, ...
'ListboxTop',0, ...
'Position',[20 48 90 15], ...
'String','Use Current Weights', ...
'Style','checkbox', ...
'ToolTipStr','If selected, the current weights are used as initial values for continued training.',...
'Tag','checkbox1');
H.Normalize_data = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.8 0.8 0.8], ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[20 231 110 15], ...
'String','Normalize Training Data', ...
'Style','checkbox', ...
'Tag','checkbox2', ...
'ToolTipStr','If selected, the reference model input-output data will be normalized.',...
'Value',1);
H.Train_con = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nnmodref'',''training_con'');', ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[100 30 75 16], ...
'String','Train Controller', ...
'ToolTipStr','Train the controller using the parameters shown in this window.',...
'Tag','Pushbutton1');
H.Rep_Train_con = 0;
H.Cont_Train_con = 0;
H.Train_NN = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nnmodref'',''training'');', ...
'Enable',window_en, ...
'ListboxTop',0, ...
'Position',[10 30 80 16], ...
'String','Plant Identification', ...
'ToolTipStr','Opens a window where you can develop the neural network plant model.',...
'Tag','Pushbutton1');
H.OK_but = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nnmodref'',''ok'')', ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[185 30 45 16], ...
'String','OK', ...
'ToolTipStr','Save the parameters into the neural network controller block and close this window.',...
'Tag','OK_but');
H.Cancel_but = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nnmodref'',''close'')', ...
'ListboxTop',0, ...
'Position',[240 30 45 16], ...
'String','Cancel', ...
'ToolTipStr','Discard the neural network controller parameters.',...
'Tag','Pushbutton1');
H.Apply_but = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nnmodref'',''apply'')', ...
'Enable','off', ...
'ListboxTop',0, ...
'Position',[295 30 45 16], ...
'String','Apply', ...
'ToolTipStr','Save the parameters into the neural network controller block.',...
'Tag','Apply_but');
H.error_messages= uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'FontWeight','bold', ...
'ForegroundColor',[0 0 1], ...
'ListboxTop',0, ...
'Position',[6 3 338 20], ...
'Style','text', ...
'ToolTipStr','Feedback line with important messages for the user.',...
'Tag','StaticText1');
H.Gen_data_but = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nnmodref'',''gen_data'')', ...
'Enable',window_en, ...
'ListboxTop',0, ...
'Position',[20 106.75 100 16.5], ...
'String','Generate Training Data', ...
'Tag','Pushbutton1', ...
'TooltipString','Generate data to be used in training the neural network controller.');
H.Get_data_file_but = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nndataimport'',''init'',gcbf,''ref'');',...
'Enable',window_en, ...
'ListboxTop',0, ...
'Position',[130 106.75 95 16.5], ...
'String','Import Data', ...
'Tag','Pushbutton1', ...
'TooltipString','Import training data from the workspace or from a file.');
H.Save_to_file_but = uicontrol('Parent',fig, ...
'Units','points', ...
'BackgroundColor',[0.752941176470588 0.752941176470588 0.752941176470588], ...
'Callback','nncontrolutil(''nndataexport'',''init'',gcbf,''ref'');',...
'Enable',window_en, ...
'ListboxTop',0, ...
'Position',[235 106.75 95 16.5], ...
'String','Export Data', ...
'Tag','Pushbutton1', ...
'TooltipString','Export training data to the workspace or to a file.');
H.Training_done=0;
H.Data_Generated=1;
H.Data_Available=0;
H.Data_Imported=0;
% We create the menus for the block.
H.Handles.Menus.File.Top= uimenu('Parent',fig, ...
'Label','File');
H.Handles.Menus.File.ImportModel = uimenu('Parent',...
H.Handles.Menus.File.Top,...
'Label','Import Network...',...
'Accelerator','I',...
'Callback','nncontrolutil(''nnimport'',''init'',gcbf,''nnmodref'',''nnmodref'');',...
'Enable',window_en, ...
'Tag','ImportModel');
H.Handles.Menus.File.Export = uimenu('Parent',H.Handles.Menus.File.Top, ...
'Label','Export Network...', ...
'Accelerator','E', ...
'Callback','nncontrolutil(''nnexport'',''init'',gcbf,''nnmodref'',''nnmodref'')', ...
'Enable',window_en, ...
'Tag','ExportMenu');
H.Handles.Menus.File.Save_NN = uimenu('Parent',...
H.Handles.Menus.File.Top,...
'Label','Save',...
'Separator','on', ...
'Enable','off', ...
'Accelerator','S',...
'Callback','nncontrolutil(''nnmodref'',''apply'');',...
'Tag','ImportModel');
H.Handles.Menus.File.Save_Exit_NN = uimenu('Parent',...
H.Handles.Menus.File.Top,...
'Label','Save and Exit',...
'Enable','off', ...
'Accelerator','A',...
'Callback','nncontrolutil(''nnmodref'',''ok'');',...
'Tag','ImportModel');
H.Handles.Menus.File.Close = uimenu('Parent',H.Handles.Menus.File.Top, ...
'Callback','nncontrolutil(''nnmodref'',''close'',gcbf);', ...
'Separator','on', ...
'Label','Exit without saving', ...
'Accelerator','X', ...
'Tag','CloseMenu');
H.Handles.Menus.Window.Top = uimenu(fig, 'Label', 'Window', ...
'Callback', winmenu('callback'), 'Tag', 'winmenu');
winmenu(fig); % Initialize the submenu
H.Handles.Menus.Help.Top = uimenu('Parent',fig, ...
'Label','Help');
H.Handles.Menus.Help.Main = uimenu('Parent',H.Handles.Menus.Help.Top, ...
'Label','Main Help', ...
'Callback','nncontrolutil(''nnmodrefhelp'',''main'');',...
'Accelerator','H');
H.Handles.Menus.Help.TrainContr = uimenu('Parent',H.Handles.Menus.Help.Top, ...
'Label','Training Controller...', ...
'Separator','on',...
'CallBack','nncontrolutil(''nnmodrefhelp'',''train_contr'');');
H.Handles.Menus.Help.PlantIdent = uimenu('Parent',H.Handles.Menus.Help.Top, ...
'Label','Plant Identification...', ...
'CallBack','nncontrolutil(''nnmodrefhelp'',''plant_ident'');');
H.Handles.Menus.Help.Simulation = uimenu('Parent',H.Handles.Menus.Help.Top, ...
'Label','Simulation...', ...
'Separator','on',...
'CallBack','nncontrolutil(''nnmodrefhelp'',''simulation'');');
H.gcbh_ptr = uicontrol('Parent',fig,'visible','off');
set(H.gcbh_ptr,'userdata',arg1);
H.gcb_ptr = uicontrol('Parent',fig,'visible','off');
set(H.gcb_ptr,'userdata',arg2);
S1c=get_param(arg1,'S1c'); % S1c is ASCII
if isempty(S1c) % If the field is empty we initialize default value.
S1c=num2str(0);
else
set(H.Hidden_layer_size,'string',S1c);
end
H.S1c_ptr = uicontrol('Parent',fig,'visible','off');
set(H.S1c_ptr,'userdata',str2num(S1c)); % S1c is saved as number
Ts=get_param(arg1,'Ts');
if isempty(Ts) % If the field is empty we initialize default value.
Ts=num2str(0);
else
set(H.Sampling_time,'string',Ts);
end
Ref_file=get_param(arg1,'Ref_file');
if isempty(Ts) % If the field is empty we initialize default value.
Ref_file='';
end
set(H.reference_model,'string',Ref_file,'UserData',struct('FileName',Ref_file,'PathName',[]));
H.Ref_file_ptr = uicontrol('Parent',fig,'visible','off');
set(H.Ref_file_ptr,'userdata',Ref_file);
Nrc=get_param(arg1,'Nrc');
if isempty(Nrc) % If the field is empty we initialize default value.
Nrc=num2str(0);
else
set(H.Delayed_ref_input,'string',Nrc);
end
H.Nrc_ptr = uicontrol('Parent',fig,'visible','off');
set(H.Nrc_ptr,'userdata',str2num(Nrc));
Nic=get_param(arg1,'Nic');
if isempty(Nic) % If the field is empty we initialize default value.
Nic=num2str(0);
else
set(H.Delayed_contr_output,'string',Nic);
end
H.Nic_ptr = uicontrol('Parent',fig,'visible','off');
set(H.Nic_ptr,'userdata',str2num(Nic));
Njc=get_param(arg1,'Njc');
if isempty(Njc) % If the field is empty we initialize default value.
Njc=num2str(0);
else
set(H.Delayed_output,'string',Njc);
end
H.Njc_ptr = uicontrol('Parent',fig,'visible','off');
set(H.Njc_ptr,'userdata',str2num(Njc));
Use_Inc_training=get_param(arg1,'Use_Inc_training');
if isempty(Use_Inc_training) % If the field is empty we initialize default value.
Use_Inc_training=num2str(0);
end
set(H.Use_Inc_training_but,'value',str2num(Use_Inc_training));
H.Use_Inc_training_ptr = uicontrol('Parent',fig,'visible','off');
set(H.Use_Inc_training_ptr,'userdata',str2num(Use_Inc_training));
Use_Previous_Weights=get_param(arg1,'Use_Previous_Weights');
if isempty(Use_Previous_Weights) % If the field is empty we initialize default value.
Use_Previous_Weights=num2str(1);
end
set(H.Use_Previous_Weights_but,'value',str2num(Use_Previous_Weights));
H.Use_Previous_Weights_ptr = uicontrol('Parent',fig,'visible','off');
set(H.Use_Previous_Weights_ptr,'userdata',str2num(Use_Previous_Weights));
sam_training_c=get_param(arg1,'sam_training_c');
if isempty(sam_training_c) % If the field is empty we initialize default value.
sam_training_c=num2str(0);
else
set(H.sam_training_c_edit,'string',sam_training_c);
end
H.sam_training_c_ptr = uicontrol('Parent',fig,'visible','off');
set(H.sam_training_c_ptr,'userdata',str2num(sam_training_c));
epochs_c=get_param(arg1,'epochs_c');
if isempty(epochs_c) % If the field is empty we initialize default value.
epochs_c=num2str(0);
else
set(H.epochs_c_edit,'string',num2str(epochs_c));
end
H.epochs_c_ptr = uicontrol('Parent',fig,'visible','off');
set(H.epochs_c_ptr,'userdata',str2num(epochs_c));
retraining_c=get_param(arg1,'retraining_c');
if isempty(ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -