0

次のような関数 ParallelPlot があります。

function ParallelPlot(hAxes, normalizedMatrix )
%//PARALLELPLOT Do Parallel Coordinates Plot for a normalized matrix
%//columns

%// Input:-
%//  o hAxes: Handle to an axes.
%//  o normalizedMatrix : n-by-m normalized matrix

DEFAULT_AXES_COLOR = [0 0 0];

[MATRIX_HEIGHT MATRIX_WIDTH] = size(normalizedMatrix);
ALL_PLOTS_MATRIX             = zeros(MATRIX_HEIGHT,MATRIX_WIDTH);


DEFAULT_MARKER_EDGE_COLOR  = [.2 .3 .4];
DEFAULT_MARKER_FACE_COLOR  = [.3 .7 .2];
DEFAULT_MARKER_SHAPE       = 's';
DEFAULT_MARKER_SIZE        = 10;
DEFAULT_MARKER_COLOR       = [1 0 0];
DEFAULT_MARKER_LINE_STYLE  = '-';
DEFAULT_MARKER_LINE_WIDTH  = 1;

SELECTED_MARKER_EDGE_COLOR = [.5 .5 .8];
SELECTED_MARKER_FACE_COLOR = [.4 .4 .6];
SELECTED_MARKER_SHAPE      = 'x';
SELECTED_MARKER_SIZE       = 15;
SELECTED_MARKER_COLOR      = [1 1 1];
SELECTED_MARKER_LINE_STYLE = '--';
SELECTED_MARKER_LINE_WIDTH = 4;

InitializeAllPlotsMatrix;
set(hAxes, 'color', DEFAULT_AXES_COLOR);
set(hAxes,'xLim',[0 MATRIX_WIDTH+1]);

    function plotHandle = InitializeNewPlot
        plotHandle = plot(hAxes           , NaN,NaN                         );
        set(plotHandle, 'Marker'          , DEFAULT_MARKER_SHAPE            );
        set(plotHandle, 'MarkerEdgeColor' , DEFAULT_MARKER_EDGE_COLOR       );
        set(plotHandle, 'MarkerFaceColor' , DEFAULT_MARKER_FACE_COLOR       );
        set(plotHandle, 'MarkerSize'      , DEFAULT_MARKER_SIZE             );
        set(plotHandle, 'LineStyle'       , DEFAULT_MARKER_LINE_STYLE       );
        set(plotHandle, 'LineWidth'       , DEFAULT_MARKER_LINE_WIDTH       );
        set(plotHandle, 'Color'           , DEFAULT_MARKER_COLOR            );
        set(plotHandle, 'ButtonDownFcn'   , @ParallelPlotButtonDownCallback );
    end

    function InitializeAllPlotsMatrix
        for i = 1 : MATRIX_HEIGHT
            for j = 1 : MATRIX_WIDTH                                
                plotHandle = InitializeNewPlot;
                hold on;
                if j <= MATRIX_WIDTH - 1
                    xDataValue   = [ j j+1];
                else
                    xDataValue = j;
                end
                if j <= MATRIX_WIDTH - 1
                    yDataValue   = [ normalizedMatrix(i,j) , normalizedMatrix(i,j+1)];
                else
                    yDataValue   = normalizedMatrix(i,j);
                end

                set(plotHandle,'xData', xDataValue,'yData', yDataValue);

                ALL_PLOTS_MATRIX(i,j) = plotHandle;
            end
        end
    end

    function ParallelPlotButtonDownCallback(plotHandle,eventHandle) %#ok<INUSD>

        [i, j] = find(ALL_PLOTS_MATRIX == plotHandle); %#ok<NASGU>

        set(ALL_PLOTS_MATRIX, 'Marker'              , DEFAULT_MARKER_SHAPE       );
        set(ALL_PLOTS_MATRIX, 'MarkerEdgeColor'     , DEFAULT_MARKER_EDGE_COLOR  );
        set(ALL_PLOTS_MATRIX, 'MarkerFaceColor'     , DEFAULT_MARKER_FACE_COLOR  );
        set(ALL_PLOTS_MATRIX, 'MarkerSize'          , DEFAULT_MARKER_SIZE        );
        set(ALL_PLOTS_MATRIX, 'LineStyle'           , DEFAULT_MARKER_LINE_STYLE  );
        set(ALL_PLOTS_MATRIX, 'LineWidth'           , DEFAULT_MARKER_LINE_WIDTH  );
        set(ALL_PLOTS_MATRIX, 'Color'               , DEFAULT_MARKER_COLOR       );

        relevantPlotsHandles = ALL_PLOTS_MATRIX(i,:);
        set(relevantPlotsHandles, 'Marker'          , SELECTED_MARKER_SHAPE      );
        set(relevantPlotsHandles, 'MarkerEdgeColor' , SELECTED_MARKER_EDGE_COLOR );
        set(relevantPlotsHandles, 'MarkerFaceColor' , SELECTED_MARKER_FACE_COLOR );
        set(relevantPlotsHandles, 'MarkerSize'      , SELECTED_MARKER_SIZE       );
        set(relevantPlotsHandles, 'LineStyle'       , SELECTED_MARKER_LINE_STYLE );
        set(relevantPlotsHandles, 'LineWidth'       , SELECTED_MARKER_LINE_WIDTH );
        set(relevantPlotsHandles, 'Color'           , SELECTED_MARKER_COLOR      );
    end
end

のような空の軸でこの関数を使用すると、正常axes()に動作しますが、GUI 軸のいずれかで使用すると、次の行で例外がスローされます。

plotHandle = plot(hAxes , NaN,NaN );

エラーは次のとおりです。

??? Error using ==> set
Invalid handle object.

Error in ==> newplot at 66
set(fig,'nextplot','add');

Error in ==> ParallelPlot>InitializeNewPlot at 37
        plotHandle = plot(hAxes           , NaN,NaN                         );

Error in ==> ParallelPlot>InitializeAllPlotsMatrix at 51
                plotHandle = InitializeNewPlot;

Error in ==> ParallelPlot at 32
InitializeAllPlotsMatrix;

このエラーが発生する理由がわかりません。これを解決する方法を知っている人はいますか?

4

1 に答える 1

0

解決策は、GUIプロパティnextplotをに設定することaddです。

ここに画像の説明を入力してください

しかし、エラーは将来のプロットのために再びスローされます!!!

于 2013-02-03T13:56:25.813 に答える