How to delete the ellipse of the previous state
2 次查看(过去 30 天)
显示 更早的评论
I want to implement an input UE ID (edit1) will display an ellipse on axes.
But I want to have only one ellipse on axes.
For example: when I enter UE ID 5 and press pushbutton, and then enter UE ID 6 and press pushbutton, axes only show the ellipse of UE ID 6.
How can I modify it?
function pushbutton2_Callback(hObject, eventdata, handles)
[UELocation] = textread('observe/mdUELocationforGUI2.txt');
InputUEID = get(handles.edit1,'String');
InputUEID = str2double(InputUEID);
InputUEID3 = InputUEID+1;
[Pairlink] = textread('observe/mdPairlinkforGUI2.txt');
Node_ID = Pairlink(InputUEID3,4); %NodeID
Node_ID2 = Node_ID+1;
[UEBeamAngle] = textread('observe/mdUEHBeamAngleforGUI2.txt');
angles_Panel_0 = UEBeamAngle;
[NodeBeam] = textread('observe/mdNodeBeamforGUI2.txt');
Node_beamnumber = NodeBeam(1,3);
[NodeBeamAngle] = textread('observe/mdNodeBeamHAngleGUI2.txt');
angles = NodeBeamAngle + 60;
axes(handles.axes1)
hold on
xUECenter=UELocation(InputUEID3,2);
yUECenter=UELocation(InputUEID3,3);
[Nodelocation] = textread('observe/mdNodeLocationXY_axisforGUI2.txt');
ROIX = Nodelocation(1,5);
ROIY = Nodelocation(1,6);
axis([0 ROIX 0 ROIY])
a = 25*ROIX/1000; %The length and width of the ellipse
b = 25*ROIX/1000;
r = a;
LineSpec='b';
plot_ellipse(a,b,r,xUECenter,yUECenter,angles_Panel_0,LineSpec)
xNodeCenter=Nodelocation(Node_ID2,2);
yNodeCenter=Nodelocation(Node_ID2,3);
r = a;
LineSpec='k';
plot_ellipse(a,b,r,xNodeCenter,yNodeCenter,angles,LineSpec)
axis equal
function plot_ellipse(a,b,r,xNodeCenter,yNodeCenter,angles,LineSpec) % Draw ellipse function
%write documentation here explaing inputs and usage
hEllipse = imellipse(gca,[-a, -b, 2*a, 2*b]);
xy = hEllipse.getVertices();
delete(hEllipse)
x = xy(:,1);
y = xy(:,2);
xy = [x y];
for k = 1 : length(angles)
theta = angles(k);
rotationArray = [cosd(theta) sind(theta); -sind(theta) cosd(theta)];
rotated_xy = xy * rotationArray;
xCenter = xNodeCenter + (r - 0.25) * cosd(theta);
yCenter = yNodeCenter + (r - 0.25) * sind(theta);
x = rotated_xy(:,1) + xCenter;
y = rotated_xy(:,2) + yCenter;
plot(x, y, LineSpec);
if k == 1
grid on;
hold on;
end
end
0 个评论
采纳的回答
Image Analyst
2020-7-2
Before you call plot(), call this function:
ClearLinesFromAxes(gca);
Here is the function:
%=====================================================================
% Erases all lines from the image axes "h".
function ClearLinesFromAxes(h)
axesHandlesToChildObjects = findobj(h, 'Type', 'line');
if ~isempty(axesHandlesToChildObjects)
delete(axesHandlesToChildObjects);
end
return; % from ClearLinesFromAxes
0 个评论
更多回答(1 个)
Voss
2020-7-2
One way might be to turn hold off before plotting your ellipse(s). If you change this:
axes(handles.axes1)
hold on
to this:
axes(handles.axes1)
hold off
Does that work?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!