www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@comparisonpane/pPlotSurface.m
function pPlotSurface(obj) %PPLOTSURFACE Private function for redrawing the display % % PPLOTSURFACE(OBJ) plots the surfaces, calculating the errors if % necessary. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. if isempty(obj.A) || isempty(obj.B) % Clear all plots i_clear2D(obj.Axes2D, obj.Line1, obj.Line2); i_clear3D(obj.Axes3D, obj.Surface1, obj.Surface2); set(obj.Message, 'String', ''); else % Clear any messages set(obj.Message, 'String', ''); A = obj.A; B = obj.B; Z1 = []; Z2 = []; switch obj.plottype case 1 Z1 = A; Z2 = B; case 2 Z1 = (A-B); case 3 Z1 = (A-B).^2; case 4 Z1 = abs(A-B); case 5 Z1 = (A-B)./A; case 6 Z1 = abs((A-B)./A); end if all(~isfinite(Z1(:))) && all(~isfinite(Z2(:))) % No finite Z numbers to get a Z range from, so graphs are not % going to be shown i_clear2D(obj.Axes2D, obj.Line1, obj.Line2); i_clear3D(obj.Axes3D, obj.Surface1, obj.Surface2); set(obj.Message, 'String', 'No finite data to display'); elseif obj.PlotDimensions==2 i_clear3D(obj.Axes3D, obj.Surface1, obj.Surface2); set(obj.Line1, 'XData', obj.xdata, 'YData', Z1); if ~isempty(Z2) set(obj.Line2, 'XData', obj.xdata, 'YData', Z2); else set(obj.Line2, 'XData', [], 'YData', []); end set(obj.Axes2D, 'XLim', mbcmakelimits(obj.xdata), ... 'YLim', mbcmakelimits([Z1(:); Z2(:)], 'loose')); elseif obj.PlotDimensions==3 i_clear2D(obj.Axes2D, obj.Line1, obj.Line2); if isempty(Z2) % Use the colored surface set(obj.Surface2, 'XData', obj.xdata, 'YData', obj.ydata, ... 'ZData', Z1, 'CData', Z1); set(obj.Surface1, 'XData', [], 'YData', [], 'ZData', []); else % Blue surface is first data set(obj.Surface1, 'XData', obj.xdata, 'YData', obj.ydata, 'ZData', Z1); set(obj.Surface2, 'XData', obj.xdata, 'YData', obj.ydata, ... 'ZData', Z2, 'CData', Z2); end set(obj.Axes3D, 'XLim', mbcmakelimits(obj.xdata), ... 'YLim', mbcmakelimits(obj.ydata), ... 'ZLim', mbcmakelimits([Z1(:); Z2(:)], 'loose')); else i_clear2D(obj.Axes2D, obj.Line1, obj.Line2); i_clear3D(obj.Axes3D, obj.Surface1, obj.Surface2); end end function i_clear2D(hAxes, hL1, hL2) set([hL1, hL2], 'XData', [], 'YData', []); set(hAxes, 'XLim', [0 1], 'YLim', [0 1]); function i_clear3D(hAxes, hS1, hS2) set([hS1, hS2], 'XData', [], 'YData', [], 'ZData', [], 'CData', []); set(hAxes, 'XLim', [0 1], 'YLim', [0 1], 'ZLim', [0 1]);