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

📄 fm_del.m

📁 一个较好的MATLAB潮流程序
💻 M
字号:
function [nomi,numero] = fm_del(nomi,numero,list_box)% FM_DEL delete a UDM variable or function%% (...) = FM_DEL(...)%%This function is generally called by a callback within%the FM_MAKE function%%Author:    Federico Milano%Date:      11-Nov-2002%Version:   1.0.0%%E-mail:    fmilano@thunderbox.uwaterloo.ca%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2005 Federico Milano%% This toolbox is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2.0 of the License, or% (at your option) any later version.%% This toolbox is distributed in the hope that it will be useful, but% WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU% General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this toolbox; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,% USA.global Algeb Buses Initl Param Servc State Figif numero == 0; return; end% general operationshlist = findobj(Fig.make,'Tag',list_box);hdl = get(Fig.make,'UserData');delbus = strcmp(list_box,'ListboxBuses');if delbus    actualnum = Buses.n;    numero = Buses.n;else    actualnum = get(hlist,'Value');    nome = nomi{actualnum,1};endnomi(actualnum) = [];numero = numero-1;set(hlist,'String',nomi,'Value',1);% other operationsswitch list_boxcase 'ListboxBuses'    % algebraic variables and equations    Algeb.idx([Buses.n 2*Buses.n]) = [];    alg_idx = strmatch(['V',int2str(Buses.n)],Algeb.name,'exact');    alg_idx = [alg_idx, strmatch(['theta',int2str(Buses.n)],Algeb.name,'exact')];    Algeb.n = Algeb.n - length(alg_idx);    Algeb.name(alg_idx) = [];    Algeb.eqidx([Algeb.neq-1 Algeb.neq]) = [];    Algeb.eq([Algeb.neq-1 Algeb.neq]) = [];    Algeb.neq = Algeb.neq - 2;    % service variables    ser_idx = strmatch(['P',int2str(Buses.n)],Servc.idx,'exact');    ser_idx = [ser_idx, strmatch(['Q',int2str(Buses.n)],Servc.idx,'exact')];    Servc.idx(ser_idx) = [];    ser_idx = strmatch(['P',int2str(Buses.n)],Servc.name,'exact');    ser_idx = [ser_idx,strmatch(['Q',int2str(Buses.n)],Servc.name,'exact')];    Servc.name(ser_idx) = [];    Servc.n = Servc.n - length(ser_idx);    % initial variables    ini_idx = strmatch(['V',int2str(Buses.n),'_0'],Initl.idx,'exact');    ini_idx = [ini_idx,strmatch(['theta',int2str(Buses.n),'_0'],Initl.idx,'exact')];    ini_idx = [ini_idx,strmatch(['P',int2str(Buses.n),'_0'],Initl.idx,'exact')];    ini_idx = [ini_idx,strmatch(['Q',int2str(Buses.n),'_0'],Initl.idx,'exact')];    Initl.idx(ini_idx) = [];    ini_idx = strmatch(['V',int2str(Buses.n),'_0'],Initl.name,'exact');    ini_idx = [ini_idx,strmatch(['theta',int2str(Buses.n),'_0'],Initl.name,'exact')];    ini_idx = [ini_idx,strmatch(['P',int2str(Buses.n),'_0'],Initl.name,'exact')];    ini_idx = [ini_idx,strmatch(['Q',int2str(Buses.n),'_0'],Initl.name,'exact')];    Initl.name(ini_idx) = [];    Initl.n = Initl.n-length(ini_idx);    % GUI settings    if isempty(Algeb.idx), set(hdl(13),'String',' ','Value',1);    else, set(hdl(13),'String',Algeb.idx,'Value',length(Algeb.idx));    end    set(hdl(6),'String',Algeb.name,'Value',Algeb.n)    set(hdl(14),'String',Servc.idx,'Value',length(Servc.idx))    set(hdl(7),'String',Servc.name,'Value',Servc.n)    if isempty(Initl.idx), set(hdl(15),'String',' ','Value',1)    else, set(hdl(15),'String',Initl.idx,'Value',1)    end    set(hdl(9),'String',Initl.name,'Value',max(Initl.n,1))    if isempty(Algeb.eq), set(hdl(11),'String',Algeb.eq,'Value',1)    else, set(hdl(11),'String',strcat(Algeb.eqidx,'=',Algeb.eq),'Value',Algeb.neq)    endcase 'ListboxServiceVar'    a = strmatch(nome,Servc.idx(end-2*Buses.n+1:end-Buses.n),'exact');    b = strmatch(nome,Servc.idx(end-Buses.n+1:end),'exact');    if isempty(a), a = 0; end    if isempty(b), b = 0; end    if a | b, return, end    Servc.type(actualnum) = [];    Servc.limit(actualnum,:) = [];    Servc.init(actualnum) = [];    Servc.offset(actualnum) = [];    Servc.un(actualnum) = [];    Servc.fn(actualnum) = [];    ser_idx = strmatch(nome,Servc.eqidx,'exact');    Servc.eqidx(ser_idx) = [];    Servc.eq(ser_idx) = [];    Servc.neq = Servc.neq - length(ser_idx);    % initial variables    init_idx = strmatch([nome,'_0'],Initl.name,'exact');    Initl.name(init_idx) = [];    Initl.n = Initl.n - 1;    init_idx = strmatch([nome,'_0'],Initl.idx,'exact');    Initl.idx(init_idx) = [];    % GUI settings    if isempty(Servc.eq), set(hdl(12),'String',Servc.eq,'Value',1)    else, set(hdl(12),'String',strcat(Servc.eqidx,'=',Servc.eq),'Value',Servc.neq)    end    set(hdl(9),'String',Initl.name,'Value',max(Initl.n,1));    if isempty(Initl.idx), set(hdl(15),'String',' ','Value',1);    else, set(hdl(15),'String',Initl.idx,'Value',1);    endcase 'ListboxState'    State.limit(actualnum,:) = [];    State.time(actualnum) = [];    State.nodyn(actualnum) = [];    State.init(actualnum) = [];    State.offset(actualnum) = [];    State.un(actualnum) = [];    State.fn(actualnum) = [];    State.neq = State.neq - 1;    State.eqidx(actualnum) = [];    State.eq(actualnum) = [];    % initial variables    init_idx = strmatch([nome,'_0'],Initl.name,'exact');    Initl.name(init_idx) = [];    Initl.n = Initl.n - 1;    init_idx = strmatch([nome,'_0'],Initl.idx,'exact');    Initl.idx(init_idx) = [];    % GUI settings    if ~State.neq, set(hdl(10),'String',State.eq,'Value',1)    else, set(hdl(10),'String',strcat(State.eqidx,' = (',State.eq,')/',State.time),'Value',State.neq);    end    set(hdl(9),'String',Initl.name,'Value',max(Initl.n,1));    if isempty(Initl.idx), set(hdl(15),'String',' ','Value',1);    else, set(hdl(15),'String',Initl.idx,'Value',1);    endcase 'ListboxParameter'    Param.type(actualnum) = [];    Param.unit(actualnum) = [];    Param.descr(actualnum) = [];end

⌨️ 快捷键说明

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