www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregmodel/multiline.m
function h= multiline(m,x,hAx,xtrans,cmodel,map,X,Y) %MULTILINE Create a multiline plot of the model % % H = MULTILINE(M, INPUT, AXES, XTRANS, CON, CMAP, X, Y) % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<3 hAx=gca; end if nargin<4 xtrans=1; end if nargin<5 cmodel= []; end if nargin<6 map= 'parula'; end if nargin<8 [Y,X]= GenTable(m,x); end hFig= ancestor(hAx,'figure'); xy=find(cellfun('prodofsize',x)>1 ); % squeeze into a 2-d plot X1= squeeze(X{xy(1)}); X2= squeeze(X{xy(2)}); Y= squeeze(Y); if ~isempty(cmodel) % evaluate boundary model and set values outside boundary to NaN cvals = constraintDistanceGrid( cmodel, x ) > 0; Y(cvals)= NaN; end s= get(m,'symbol'); labs = InputLabels(m); if ~xtrans labs(xy(1:2))= labs(xy([2 1])); s(xy(1:2))= s(xy([2 1])); X1=X2'; X2=squeeze(X{xy(1)})'; Y= Y'; end axes(hAx) % set up color map cm = feval(map,size(X1,2)); % plot the lines h = plot(X1,Y,'Parent',hAx); set(h,{'Color'},num2cell(cm,2)) xregGui.setLegendData(h, 'Model fit'); % write on numbers for each line %The line end coords are the final numbers that are finite in each row %(NaNs are placed in Y there by the boundary constraint). for i = 1:size(X2,2) idx = find(isfinite(Y(:,i)), 1, 'last'); if ~isempty(idx) yText = Y(idx, i); xText = X1(idx, i); else yText = NaN; xText = NaN; end th = text(xText,yText, sprintf(' %s=%.6g', s{xy(2)}, X2(end,i)), ... 'Color',cm(i,:),... 'Parent',hAx); if xText> hAx.XLim(2)- 0.01*diff(hAx.XLim) th.HorizontalAlignment = 'right'; end end set(hAx,'Box','on','XGrid','on','YGrid','on') set(get(hAx,'XLabel'),... 'String',labs{xy(1)},'Interpreter','none'); lab = ResponseLabel(m); set(get(hAx,'YLabel'),... 'String',lab,'Interpreter','none'); set(get(hAx,'Title'),... 'String',lab,'Interpreter','none');