在 MATLAB 中使用补丁时出错
Error using patch in MATLAB
我正在创建一个使用 patch
函数进行放大的拖动框。拖动时出现以下错误:
Error using patch
Not enough input arguments.
Error in boxReady (line 31)
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
repmat(vabls.CurrentPoint(1,1),[1 4]), ...
repmat(vabls.CurrentPoint(1,2),[1 4]));
这是我使用的代码:
% This is the point the cursor is at when the user presses down. drawBox is called again
% when the button is released and the current point then is the other corner of the patch
vabls.CurrentPoint = get(guiele.ResponsePlotAxis,'CurrentPoint');
set(guiele.ResponsePlotLine,'erasemode','none');
XYLims=[get(guiele.ResponsePlotAxis,'xlim') get(guiele.ResponsePlotAxis,'ylim')];
axes(guiele.ResponsePlotAxis);
hold on;
if ishandle(guiele.dragBox)
delete(guiele.dragBox);
end
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
repmat(vabls.CurrentPoint(1,1),[1 4]), ...
repmat(vabls.CurrentPoint(1,2),[1 4]));
set(guiele.dragBox,'FaceColor','none','EdgeColor','r','LineStyle',':');
% initialize some varaiables
guiele.ResponsePlotAxis=-1;
guiele.dragBox = -1;
每个补丁 patch
(or 4-argument form including an axes handle) requires that you also enter color data 的三参数形式:
patch(X, Y, C);
% Or ...
patch(ax, X, Y, C);
如果不想输入颜色数据,可以使用下面的形式:
patch(ax, 'XData', X, 'YData', Y);
因此您对 patch
的调用将如下所示:
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
'XData', repmat(vabls.CurrentPoint(1, 1), [1 4]), ...
'YData', repmat(vabls.CurrentPoint(1, 2), [1 4]));
我正在创建一个使用 patch
函数进行放大的拖动框。拖动时出现以下错误:
Error using patch
Not enough input arguments.
Error in boxReady (line 31)
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
repmat(vabls.CurrentPoint(1,1),[1 4]), ...
repmat(vabls.CurrentPoint(1,2),[1 4]));
这是我使用的代码:
% This is the point the cursor is at when the user presses down. drawBox is called again
% when the button is released and the current point then is the other corner of the patch
vabls.CurrentPoint = get(guiele.ResponsePlotAxis,'CurrentPoint');
set(guiele.ResponsePlotLine,'erasemode','none');
XYLims=[get(guiele.ResponsePlotAxis,'xlim') get(guiele.ResponsePlotAxis,'ylim')];
axes(guiele.ResponsePlotAxis);
hold on;
if ishandle(guiele.dragBox)
delete(guiele.dragBox);
end
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
repmat(vabls.CurrentPoint(1,1),[1 4]), ...
repmat(vabls.CurrentPoint(1,2),[1 4]));
set(guiele.dragBox,'FaceColor','none','EdgeColor','r','LineStyle',':');
% initialize some varaiables
guiele.ResponsePlotAxis=-1;
guiele.dragBox = -1;
每个补丁 patch
(or 4-argument form including an axes handle) requires that you also enter color data 的三参数形式:
patch(X, Y, C);
% Or ...
patch(ax, X, Y, C);
如果不想输入颜色数据,可以使用下面的形式:
patch(ax, 'XData', X, 'YData', Y);
因此您对 patch
的调用将如下所示:
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
'XData', repmat(vabls.CurrentPoint(1, 1), [1 4]), ...
'YData', repmat(vabls.CurrentPoint(1, 2), [1 4]));