MATLAB Answers

Trevor
0

Better data tip for Polar graph

Asked by Trevor
on 7 Aug 2011
Latest activity Answered by Mike Garrity
on 12 May 2016
Is there any way to make Matlab give polar coordinates when placing a data tip on a graph instead of Cartesian?
And really, why on earth does Matlab not do that in the first place?

  0 Comments

Sign in to comment.

Tags

Products

3 Answers

Answer by Oleg Komarov on 8 Aug 2011

At the end of the documentation of datacursormode you will find example on how to customze the text of the tip.

  0 Comments

Sign in to comment.


Answer by George Sterling on 12 May 2016
Edited by George Sterling on 12 May 2016

% This function changes data tips from cartessian to polar coords
function polar_datacursormode
dcm_obj = datacursormode(gcf); set(dcm_obj,'UpdateFcn',@myupdatefcn)
function txt = myupdatefcn(empt,event_obj) % Customizes text of data tips
pos = get(event_obj,'Position');
R = sqrt(pos(1)^2 + pos(2)^2);
Theta = atand(pos(2)/pos(1));
if Theta < 0 Theta = Theta + 360; end
txt = {['R: ' num2str®], ... ['Theta: ' num2str(Theta)]};

  0 Comments

Sign in to comment.


Answer by Mike Garrity
on 12 May 2016

The new polarplot function in R2016a does this for you.

  0 Comments

Sign in to comment.