www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@comparisonpane/setdata.m

    function setdata(obj, A, B, xdata, xname, ydata, yname)
%SETDATA Set new data for display
%
%  SETDATA(OBJ, A, B, xdata, xname, ydata, yname) sets data for display in a
%  3D graph.
%
%  SETDATA(OBJ, A, B, xdata, xname) sets data for display in a 2D graph.
%
%  SETDATA(OBJ, A, B) just updates the current sets of data.
%
%  SETDATA(OBJ, 'message') clears the display and displays the string
%  "message" in the axes.

%  Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin==2 && ischar(A)
    % Call this function again to clear the axes properly
    if obj.PlotDimensions==2
        obj.setdata([],[],[],'');
    else
        obj.setdata([],[],[],'',[],'');
    end
    
    % Set a message
    set(obj.Message, 'String', A);
    return
end


if nargin<7
    yname = '';
end
if nargin<6
    ydata = [];
end

% Save the input data
if nargin>3
    obj.xdata = xdata;
    obj.ydata = ydata;

    % Set input labels on graphs
    mbcxlabel(obj.Axes2D, xname);
    mbcxlabel(obj.Axes3D, xname);
    mbcylabel(obj.Axes3D, yname);
end

% Switch cards if required
if nargin >3
    if isempty(yname)&& isempty(ydata)
        % 2D
        obj.PlotDimensions = 2;
    else
        % 3D
        obj.PlotDimensions = 3;
    end
end

% Update the surfaces or lines
obj.A = A;
obj.B = B;
obj.pPlotSurface;