MATLAB: Polar Plot with a moving marker

polar plot

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!

Best Answer

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);
Related Question