Polar Plot with a moving marker
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nik Sofoulis
el 4 de Sept. de 2014
Editada: Nik Sofoulis
el 19 de Sept. de 2014
Hi to everyone
I am trying to plot Array Factor of an antenna using Polar2 function. I would like to know if there is any way to have a moving marker above the plot which it will follow the cursor of mouse. More specific i want to show the dBs of Array Factor as regards to angle. I want to draw a marker, which will be like a radius, and will be moving arround the circle (as regards to mouse) of polar plot and in a given angle it will show the dBs. It follows an image of a polar plot and the marker is with purple.
Thank you in advance!

0 comentarios
Respuesta aceptada
Joseph Cheng
el 4 de Sept. de 2014
Not entirely sure what you mean by move around the circle but here is an example:
function clicktest()
theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
figure
ax(1) = polar(theta,rho,'--r');
hold on
ax(2) = polar(NaN,NaN,'g*');
set (gcf, 'WindowButtonMotionFcn', {@mouseMove,ax});
function mouseMove(object, eventdata,ax)
C = get (gca, 'CurrentPoint');
[theta rho] = cart2pol(C(1,1), C(1,2));
title(gca, ['(angle,factor) = (', num2str(theta*180/pi), ', ',num2str(rho), ')']);
markerspot = sin(2*theta).*cos(2*theta);
[x y]=pol2cart(theta,markerspot);
set(ax(2),'xData',x,'yData',y,'markersize',20);
4 comentarios
Joseph Cheng
el 5 de Sept. de 2014
oh if you want to track the mouse then instead of calculating the marker spot just substitute the x and y data for C(1,1) and C(1,2). the return for mouse position is stored in C.
Nik Sofoulis
el 5 de Sept. de 2014
Editada: Nik Sofoulis
el 5 de Sept. de 2014
Más respuestas (1)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


