Polar Plot with a moving marker
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Joseph Cheng
2014-9-4
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 个评论
Joseph Cheng
2014-9-5
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!