Borrar filtros
Borrar filtros

How to delete the ellipse of the previous state

1 visualización (últimos 30 días)
han han
han han el 2 de Jul. de 2020
Respondida: Image Analyst el 2 de Jul. de 2020
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

Respuesta aceptada

Image Analyst
Image Analyst el 2 de Jul. de 2020
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

Más respuestas (1)

Voss
Voss el 2 de Jul. de 2020
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?

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by