📄 neffilla.m
字号:
function S_and_P = neffilla(fig)%NEFFILLA creates the constraint bounds and does some data checking.%% Modified version of FILLAXES.%% S_and_P = FILLAXES(FIG) creates the upper and lower % constraint bounds and patches in the constraint figure FIG. % It also does some error checking on the matrices NCD_LB and % NCD_UB.%% The output S_and_P contains the handles of the bounds and% patches.%% See also MAKESURF.% Author(s): A. Potvin, 12-1-92% Copyright (c) 1992-93 by The MathWorks, Inc.% $Revision: 1.13 $ $Date: 1993/11/02 23:34:06 $% Modified: Andreas Nuernberger; DASA Airbus; June 1996global NCD_UB NCD_LB RANGE_LIMIT% Default output (in case of error) and definitionsS_and_P = zeros(1,4);ud = get(fig,'UserData');out = ud(1,2);sys = get(ud(1,6),'UserData');% Get start and final timeif isempty(RANGE_LIMIT), % Get tstart and tfinal from SIMULINK % Use eval('try','catch') in case system name changed %eval([sys '([],[],[],0);'],'errorncd(10); return'); tstart = get_param(sys,'Start time'); tfinal = get_param(sys,'Stop time'); % Hack: 4.1x get_param returns strings, 4.0 and 4.1 sometimes returned numbers if isstr(tstart), % No need for protected eval('try','catch') tstart = eval(tstart); tfinal = eval(tfinal); end RANGE_LIMIT = [tstart tfinal];else tstart = RANGE_LIMIT(1,1); tfinal = RANGE_LIMIT(1,2);end% If no lower bounds defined, use defaultDoDefault = 0;if isempty(NCD_LB), DoDefault = 1;elseif isempty(find(NCD_LB(1,:)==out)), DoDefault = 1;endif DoDefault, dt = tfinal-tstart; ylim = get(gca, 'Ylim');% lb = ylim(1) + (ylim(2)-ylim(1))*.1;% NCD_LB = [NCD_LB, ...% [out*ones(1,4); ...% tstart+[0 0.5*dt 0.5*dt] tfinal; ...% lb lb lb lb; ...% 1 0 1 0]];% lb = ylim(2)-ylim(1)*0.9;% NCD_LB = [NCD_LB, ...% [ out*ones(1,6); ...% tstart+[0 0.1*dt 0.1*dt 0.3*dt 0.3*dt] tfinal; ...% [-0.01 -0.01 0.9 0.9 0.99 0.99]*lb; ...% 1 0 1 0 1 0]]; lb = ylim(2)-ylim(1)*0.9; NCD_LB = [NCD_LB, ... [ out*ones(1,6); ... tstart+[0 0.23*dt 0.23*dt 0.3*dt 0.3*dt] tfinal; ... [-0.01 -0.01 0.9 0.9 0.99 0.99]; ... 1 0 1 0 1 0]];end% If no upper bounds defined, use defaultDoDefault = 0;if isempty(NCD_UB), DoDefault = 1;elseif isempty(find(NCD_UB(1,:)==out)), DoDefault = 1;endif DoDefault, dt = tfinal-tstart; ylim = get(gca, 'Ylim');% ub = ylim(2) - (ylim(2)-ylim(1))*.1;% NCD_UB = [NCD_UB, ...% [out*ones(1,4); ...% tstart+[0 0.5*dt 0.5*dt] tfinal; ...% ub ub ub ub; ...% 1 0 1 0]];% ub = (ylim(2)-ylim(1))*0.9;% NCD_UB = [NCD_UB, ...% [ out*ones(1,4); ...% tstart+[0 0.3*dt 0.3*dt] tfinal; ...% [1.2 1.2 1.01 1.01]*ub; ...% 1 0 1 0]]; NCD_UB = [NCD_UB, ... [ out*ones(1,6); ... tstart+[0 0.19*dt 0.19*dt 0.3*dt 0.3*dt] tfinal; ... [0.01 0.01 1.1 1.1 1.01 1.01]; ... 1 0 1 0 1 0]];end% Do some error checking% Four rows% Outputs are integers% Even number of columns for every output% x(i+1)>x(i) for i = 1:size(x,2)-1% x(i+1)=x(i) for i = 2:2:size(x,2)-2error_str = '';tmp = NCD_LB;for i=[1 2], if size(tmp,1)~=4, % Constraint bound must have four rows error_str = 'fillaxes: Constraint bounds must have four rows. '; elseif any(tmp(1,:)~=round(tmp(1,:))), error_str = 'fillaxes: Outports must be integers. '; else index = find(tmp(1,:)==out); x = tmp(2,index); l = length(index); % Error checks if rem(l,2)~=0, error_str = 'fillaxes: Constraint bounds must be line segments .'; elseif any(x(2:l)<x(1:l-1)) error_str = 'fillaxes: Constraint bound time vector must be monotonic. '; elseif any(x(2:2:l-2)~=x(3:2:l-1)), error_str = 'fillaxes: Constraint bound segments should begin where another ends. '; end % if if ~isempty(error_str), break end end % if right number of columns % Terminate loop after an error if ~isempty(error_str) errordlg([error_str int2str(i)]); return end tmp = NCD_UB;end% Make sure lower limits go from start time to final timeN1 = [];N2 = [];tmp = (NCD_LB(1,:)==out);INDEX = find(tmp);ylim(1) = min(NCD_LB(3,INDEX));i1 = INDEX(1);if NCD_LB(2,i1)>tstart, N1 = [out out; tstart NCD_LB(2,i1); [1 1]*NCD_LB(3,i1); 1 0];endi1 = INDEX(length(INDEX));if NCD_LB(2,i1)<tfinal, N2 = [out out; NCD_LB(2,i1) tfinal; [1 1]*NCD_LB(3,i1); 1 0];endif ~isempty([N1 N2]), NCD_LB = [NCD_LB(:,find(~tmp)) N1 NCD_LB(:,INDEX) N2];end% Make sure upper limits go from start time to final timeN1 = [];N2 = [];tmp = (NCD_UB(1,:)==out);INDEX = find(tmp);ylim(2) = max(NCD_UB(3,INDEX));i1 = INDEX(1);if NCD_UB(2,i1)>tstart, N1 = [out out; tstart NCD_UB(2,i1); [1 1]*NCD_UB(3,i1); 1 0];endi1 = INDEX(length(INDEX));if NCD_UB(2,i1)<tfinal, N2 = [out out; NCD_UB(2,i1) tfinal; [1 1]*NCD_UB(3,i1); 1 0];endif ~isempty([N1 N2]), NCD_UB = [NCD_UB(:,find(~tmp)) N1 NCD_UB(:,INDEX) N2];end% Set axes limitsax = get(fig,'CurrentA');ylim = ylim + diff(ylim)*[-1 1]/10;%if size(RANGE_LIMIT,1)>=out+1, % Note: zeros denote y-axis should auto-scale% if any(RANGE_LIMIT(out+1,:)~=[0 0]),% ylim = RANGE_LIMIT(out+1,:);% end%endyaxl = get(ax, 'YLim');ylim(1) = min(yaxl(1), ylim(1)); ylim(2) = max(yaxl(2), ylim(2)); set(ax,'XLim',RANGE_LIMIT(1,:),'YLim',ylim);%set(ax,'XLim',RANGE_LIMIT(1,:));% Finally draw constraint bounds for this outputindex = find(NCD_LB(1,:)==out);bound = NCD_LB(2:4,index);NCD_LB(:,index) = [];[toosmall,bound] = dividecb(bound,tstart);[bound,toolarge] = dividecb(bound,tfinal);[S_and_P(1),S_and_P(3)] = makesurf(fig,bound,1);bound = [toosmall bound toolarge];bound = [out*ones(1,size(bound,2)); bound];NCD_LB = [NCD_LB bound];index = find(NCD_UB(1,:)==out);bound = NCD_UB(2:4,index);NCD_UB(:,index) = [];[toosmall,bound] = dividecb(bound,tstart);[bound,toolarge] = dividecb(bound,tfinal);[S_and_P(2),S_and_P(4)] = makesurf(fig,bound,2); bound = [toosmall bound toolarge];bound = [out*ones(1,size(bound,2)); bound];NCD_UB = [NCD_UB bound];% end fillaxes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -