show2DCons

PURPOSE ^

% Method of optiGTest class

SYNOPSIS ^

function h=show2DCons(obj,XX,YY,ZZ,statusZ,txt,funName)

DESCRIPTION ^

% Method of optiGTest class
 L. LAURENT --  17/05/2018 -- luc.laurent@lecnam.net

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Method of optiGTest class
0002 % L. LAURENT --  17/05/2018 -- luc.laurent@lecnam.net
0003 
0004 % sources available here:
0005 % https://bitbucket.org/luclaurent/optigtest/
0006 % https://github.com/luclaurent/optigtest/
0007 
0008 % optiGTest - set of testing functions    A toolbox to easy manipulate functions.
0009 % Copyright (C) 2018  Luc LAURENT <luc.laurent@lecnam.net>
0010 %
0011 % This program is free software: you can redistribute it and/or modify
0012 % it under the terms of the GNU General Public License as published by
0013 % the Free Software Foundation, either version 3 of the License, or
0014 % (at your option) any later version.
0015 %
0016 % This program is distributed in the hope that it will be useful,
0017 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0018 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0019 % GNU General Public License for more details.
0020 %
0021 % You should have received a copy of the GNU General Public License
0022 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
0023 
0024 
0025 %% show 2D function wiyth constraints
0026 % INPUTS:
0027 %  - XX, YY: meshgrid used for ploting
0028 %  - ZZ, GZ: responses and gradients of 1 or many functions (stored in cell)
0029 %  - statusZ: status of the constraint (stored in cell)
0030 %  - txt: text to display in title [optional]
0031 %  - funName: name the functions (stored in cell) [optional]
0032 % OUTPUTS:
0033 %  - h: handle of the figure
0034 
0035 function h=show2DCons(obj,XX,YY,ZZ,statusZ,txt,funName)
0036 nbC=2;
0037 nbLevel=10;
0038 %
0039 if nargin<6;funName{1}='';end
0040 if nargin<5;txt=[];end
0041 %
0042 if iscell(ZZ)
0043     nbR=numel(ZZ);
0044     if numel(funName)==1&&nbR~=1
0045         funName=repmat({''},1,nbR);
0046     end
0047 else
0048     nbR=1;
0049     nbC=2;
0050     %
0051     ZZ={ZZ};
0052 end
0053 if ~iscell(statusZ)
0054     statusZ={statusZ};
0055 end
0056 %manage status of the constraint(s)
0057 statusDouble=cellfun(@double,statusZ,'UniformOutput',false);
0058 matStatus=cat(3,statusDouble{:});
0059 fullStatus=prod(matStatus,3);
0060 fullStatus(fullStatus==0)=NaN;
0061 %deactivate violated values
0062 ZZplot=cellfun(@(x)fullStatus.*x,ZZ,'UniformOutput',false);
0063 %
0064 spaceX=[obj.xMin(1) obj.xMax(1)];
0065 spaceY=[obj.xMin(2) obj.xMax(2)];
0066 %
0067 h=figure('NumberTitle', 'off', 'Name', [txt ' function']);
0068 itS=1;
0069 warning off all;
0070 for itR=1:numel(ZZ)
0071     subplot(nbR,nbC,itS)
0072     surfCustom(XX,YY,ZZplot{itR});
0073     axis('tight','square')
0074     xlabel('x'), ylabel('y'), title(funName{itR})
0075     xlim(spaceX)
0076     ylim(spaceY)
0077     %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0078     subplot(nbR,nbC,itS+1)
0079     contourf(XX,YY,ZZplot{itR},nbLevel);
0080     axis('tight','square')
0081     xlabel('x'), ylabel('y'), title(funName{itR})
0082     xlim(spaceX)
0083     ylim(spaceY)
0084     %
0085     itS=itS+2;
0086 end
0087 warning on all;
0088 end

Generated on Tue 28-May-2019 16:00:34 by m2html © 2005