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

📄 nefgui.m

📁 模糊神经网络采用matlab编程 o install NEFCON follow these steps: 1. Unpack the tar file NEFCON.TAR into your MA
💻 M
📖 第 1 页 / 共 3 页
字号:
    end 
    if nargin < 2,  
        p1 = ''; 
    end  
  
    hndl=findobj(NEFCON_UIH, 'Tag','status');  
    if hndl == [],  
        % control is probably closed - clear global NEFCON_UIH to prevent subsequent calls...  
        NEFCON_UIH = [];  
    else  
        % reset all colors 
        set(hndl, 'BackgroundColor',statdColor); 
        if NEFCON_STAT >=1 &  NEFCON_STAT <=5 
            set(NEFCON_SHANDLE(NEFCON_STAT+1), 'BackgroundColor',yellow); 
            % redraw text - delay in X-Systems 
            set(NEFCON_SHANDLE(NEFCON_STAT+1), 'String', get(NEFCON_SHANDLE(NEFCON_STAT+1), 'String')); 
        elseif NEFCON_STAT ==0  
            set(NEFCON_SHANDLE(NEFCON_STAT+1), 'BackgroundColor',stateColor); 
        end  
        hndl=findobj(NEFCON_UIH, 'Tag','stattxt');  
        if NEFCON_ACTCYC == [] | NEFCON_ACTCYC == 0 
            set(hndl, 'String', ['Status: ' p1]);  
        else  
            set(hndl, 'String', ['Status: ' p1 '  [Cycle: ' num2str(NEFCON_ACTCYC) ']']);  
        end  
        drawnow; 
    end  
  
    % enable/disable create button  
    if NEFCON_STAT == 0  
        tagset(NEFCON_UIH, 'create', 'enable','on');  
    else  
        tagset(NEFCON_UIH, 'create', 'enable','off');  
    end  
 
    % enable/disable simulate button  
    hndl=findobj(NEFCON_UIH, 'Tag','simub');  
    if NEFCON_STAT == 0 | NEFCON_STOP == 1 
        set(hndl,'enable','on');  
    else  
        set(hndl,'enable','off');  
    end  
    if NEFCON_STOP == 1 
        set(hndl,'String','Continue');  
    else 
        set(hndl,'String','Simulate');  
    end  
 
    % enable/disable stop button  
    hndl=findobj(NEFCON_UIH, 'Tag','stopb');  
    if NEFCON_STAT == 0 | NEFCON_STOP == 1 
        set(hndl,'enable','off');  
    else  
        set(hndl,'enable','on');  
    end  
  
    % enable/disable skip buttons  
    hndl=findobj(NEFCON_UIH, 'Tag','bckb');  
    if NEFCON_STAT > 2 & NEFCON_STAT < 6  
        set(hndl,'enable','on');  
    else  
        set(hndl,'enable','off');  
    end  
    hndl=findobj(NEFCON_UIH, 'Tag','forwb');  
    if NEFCON_STAT > 0 & NEFCON_STAT < 5  
        set(hndl,'enable','on');  
    else  
        set(hndl,'enable','off');  
    end  
 
    % enable/disable fuzzy controller button  
    hndl=findobj(NEFCON_UIH, 'Tag','fuzzyc');  
    if NEFCON_FIS == []  
        set(hndl,'enable','off');  
    else  
        set(hndl,'enable','on');  
    end  
  
    %enable/disable other tools  
    nefgui_o('actualize');  
  
 
elseif strcmp(action, 'statl') 
    if p1 ~= [] 
        if NEFCON_STAT == 0  
            NEFCON_STATEX(p1-1) = get(NEFCON_SHANDLE(p1), 'Value');  
        else  
            nefgui('status','NEFCON: Could not change setting during execution.');  
            set(NEFCON_SHANDLE(p1), 'Value', NEFCON_STATEX(p1-1));  
        end  
    end 
 
elseif strcmp(action, 'rulelist'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'rulelist');  
    if hndl ~= [],  
        if NEFCON_STAT == 0,  
            NEFCON_RULE = get(hndl, 'Value');  
        else  
            disp('NEFCON: Could not change rule-learning during execution.');  
            set(hndl, 'Value', NEFCON_RULE);  
        end  
    end  
  
elseif strcmp(action, 'opt'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'opt');  
    if hndl ~= [],  
        if NEFCON_STAT == 0,  
            NEFCON_OPT = get(hndl, 'Value');  
        else  
            nefgui('status', 'INFORMATION: optimization type changed.');  
            NEFCON_OPT = get(hndl, 'Value');  
%            disp('NEFCON: Could not change optimization type during execution.');  
%            set(hndl, 'Value', NEFCON_OPT);  
        end  
    end  
  
elseif strcmp(action, 'ferr'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'ferr');  
    if hndl ~= [],  
        if NEFCON_STAT == 0,  
            NEFCON_FERR = get(hndl, 'Value');  
        else  
            disp('NEFCON: Could not change error type during execution.');  
            set(hndl, 'Value', NEFCON_FERR);  
        end  
    end  
  
elseif strcmp(action, 'inifismat'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'inifismat');  
    if hndl ~= [],  
        if NEFCON_STAT == 0,  
            NEFCON_IFM = get(hndl, 'String');  
        else  
            disp('NEFCON: Could not change initial fismatrix during execution.');  
            set(hndl, 'String', NEFCON_IFM);  
        end  
    end  
  
elseif strcmp(action, 'errfismat'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'errfismat');  
    if hndl ~= [],  
        if NEFCON_STAT == 0,  
            NEFCON_EFMN = get(hndl, 'String');  
        else  
            disp('NEFCON: Could not change error fismatrix during execution.');  
            set(hndl, 'String', NEFCON_EFMN);  
        end  
    end  
  
elseif strcmp(action, 'rate'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'rate');  
    if hndl ~= [],  
        data = str2num(get(hndl, 'String'));  
        if data<0,  
            nefgui('status', 'ERROR: Rate must be positive.')  
            set(hndl, 'String', num2str(NEFCON_RATE));  
        else  
            NEFCON_RATE = data;  
            if NEFCON_STAT > 0,  
                nefgui('status', 'INFO: Rate changed.');  
            end  
        end  
    end  
  
elseif strcmp(action, 'load'),  
    [fn, path] = uigetfile ('*.nef', 'Load Nefcon settings');  
    if fn ~= 0  
        %load settings  
        if exist([path fn]) == 0  
            nefgui('status', 'WARNING: File not found!');  
        else  
            % set globals  
            eval(['load ' [path fn] ' -mat; nefmat(nefsmat);']);     % loads matrix smat  
            nefgui('status', 'INFO: Settings loaded.');  
            % update display 
            nefgui('cycles', 'set');  
            nefgui('nofinp');  
        end  
    end  
  
elseif strcmp(action, 'save'),  
    [fn, path] = uiputfile ('*.nef', 'Save Nefcon settings');  
    if fn == 0  
        nefgui('status', 'WARNING: Settings not saved!');  
    else  
        %get current settings  
        if find(fn=='.') == []  
            % append filename extension (error in uiputfile: appends .mat)  
            fn = [fn '.nef'];         
        end  
        eval(['nefsmat = nefmat; save ' [path fn] ' nefsmat;']);  
        nefgui('status', 'INFO: Settings saved.');  
    end  
  
elseif strcmp(action, 'new'),  
    %load default settings  
    if exist('default.nef') == 0  
        nefgui('status', 'WARNING: File ''default.nef'' not found!');  
    else  
        % set globals  
        eval(['load default.nef -mat; nefmat(nefsmat);']);     % loads matrix smat  
        nefgui('status', 'INFO: Default settings loaded.');  
    end  
  
elseif strcmp(action, 'savef'),  
    if NEFCON_FIS == []  
        nefgui('status', 'ERROR: Fismatrix is empty.');  
    else  
        [fn, path] = uiputfile ('*.fis', 'Save Nefcon fismatrix');  
        if fn == 0  
            nefgui('status', 'WARNING: Matrix not saved!');  
        else  
            %save  
            if find(fn=='.') == []  
                % append filename extension (error in uiputfile: appends .mat)  
                fn = [fn '.fis'];   
            end  
            writefis(NEFCON_FIS, [path fn]);  
            nefgui('status', 'INFO: Matrix saved.');  
        end  
    end  
  
elseif strcmp(action, 'loadf'),  
    [fn, path] = uigetfile ('*.fis', 'Load Nefcon fismatrix');  
    if fn ~= 0  
        %load  
        if exist([path fn]) == 0  
            nefgui('status', 'WARNING: File not found!');  
        else  
            % set  
            NEFCON_FIS = readfis([path fn]);  
            nefgui('status', 'INFO: Matrix loaded.');  
        end  
    end  
 
elseif strcmp(action, 'start'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'start');  
    if hndl ~= [],  
        data = str2num(get(hndl, 'String'));  
        if data<0,  
            nefgui('status', 'ERROR: Illegal Number.')  
            set(hndl, 'String', get_param(NEFCON_SYSNAME,'Start time'));  
        else  
            set_param(NEFCON_SYS,'Start time', num2str(data))  
        end  
    end  
elseif strcmp(action, 'stop'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'stop');  
    if hndl ~= [],  
        data = str2num(get(hndl, 'String'));  
        if data<0,  
            nefgui('status', 'ERROR: Illegal Number.')  
            set(hndl, 'String', get_param(NEFCON_SYSNAME,'Stop time'));  
        else  
            set_param(NEFCON_SYSNAME,'Stop time', num2str(data))  
        end  
    end  
elseif strcmp(action, 'step'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'step');  
    if hndl ~= [],  
        data = str2num(get(hndl, 'String'));  
        if data<0,  
            nefgui('status', 'ERROR: Illegal Number.')  
            set(hndl, 'String', get_param(NEFCON_SYSNAME,'Min step size'));  
        else  
            set_param(NEFCON_SYSNAME,'Min step size', num2str(data))  
            set_param(NEFCON_SYSNAME,'Max step size', num2str(data))  
        end  
    end  
elseif strcmp(action, 'cycles'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'cycles');  
    if hndl ~= [],  
        if nargin<2, % set from input  
            data = str2num(get(hndl, 'String'));  
            if data<1,  
                nefgui('status', 'ERROR: Illegal Number.')  
                set(hndl, 'String', num2str(NEFCON_CYC));  
            else  
                NEFCON_CYC = data;  
            end  
        else  
            if NEFCON_RBT == 3 & NEFCON_RBT1 == 3 & NEFCON_OBT == 3,  
               NEFCON_CYC = NEFCON_RBND + NEFCON_RBND1 + NEFCON_OBND;    % nof cycles  
            end  
            set(hndl, 'String', num2str(NEFCON_CYC));  
        end  
    end  
elseif strcmp(action, 'nofinp'),  
    hndl=findobj(NEFCON_UIH, 'Tag', 'nofinp');  
    if hndl ~= [],  
        set(hndl, 'String', ['( ' num2str(NEFCON_NUMIN) ' inputs )']);  
    end  
 
elseif strcmp(action, 'simulate'),  
    hndl=findobj(NEFCON_UIH, 'Tag','simub');  
    if hndl ~= [],  
        % reset time/states for simulate 
        if strcmp(setstr(get(hndl, 'string')), 'Simulate') 
            NEFCON_TIME = []; 
            NEFCON_X0 = []; 
            NEFCON_YS = []; 
            NEFCON_ACTCYC = 0;  
        end 
    end 
    nefsim;  
 
elseif strcmp(action, 'shwlps'),  
    [fn, path] = uigetfile ('*.mat', 'Select loop directory');  
    if path ~= 0  
		nefdlp(path);
    end  

elseif strcmp(action, 'reset'),  
    %clear all;  
    NEFCON_STOP = 0;  
    NEFCON_STAT = 0;  
    NEFCON_ACTCYC = 0;  
    nefdef;  
    nefgui('status');  
    nefgui('rulelist');  
    nefgui('opt');  
    nefgui('rate');  
    nefgui('ferr');  
    nefgui('inifismat');  
    nefgui('errfismat');  
    nefgui('cycles', 'set'); 
    tagset(NEFCON_UIH, 'status', 'Value', 1);   
    NEFCON_STATEX = ones(1, 7); 
  
elseif strcmp(action, ''),  
    % popup window  
    nefgui('cycles', NEFCON_CYC);  
    set(NEFCON_UIH,'visible','on');  
    figure(NEFCON_UIH); 
  
else  
    disp(['nefgui: illegal action (' action ')']);  
end  
  

⌨️ 快捷键说明

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