specify regions in compass

2 views (last 30 days)
Ahmed Siddig
Ahmed Siddig on 9 Jun 2018
Answered: Abby Skofield on 4 Oct 2024
how can i specify the readings in compass function to display them in a specific region. for example when i enter
y=(9+170)
and i want it to display in (225,315) region or make the reading in (-,-) region how can i do that thank you in advance
  2 Comments
Walter Roberson
Walter Roberson on 9 Jun 2018
Are you asking how to restrict the graphic output of compass() to a particular range of angles ?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Jun 2018
For the case of compass(Z) with one variable, start with
U = real(Z);
V = imag(Z);
and then continue as for the case with two variables:
nu = numel(U);
[th,r] = cart2pol([zeros(nu,1), U(:), nan(nu,1)], [zeros(nu,1), V(:), nan(nu,1)]);
polarplot(th.', r.', 'b');
ax = gca;
if isprop(ax, 'ThetaLim')
ax.ThetaLim = [225, 315];
else
warning('Cannot restrict angle when you are plotting with hold on');
end
I did not go to the trouble of putting the arrowheads on the output.
  7 Comments
Walter Roberson
Walter Roberson on 13 Jun 2018
Sorry, I do not understand where the points should be moved to, or what angle they should end up pointing.
Ahmed Siddig
Ahmed Siddig on 14 Jun 2018
Sorry about that but you did solve it for me with
ax.ThetaLim = [225, 315]; thank you for that, and sorry i forgot to accept the answer.

Sign in to comment.

More Answers (1)

Abby Skofield
Abby Skofield on 4 Oct 2024
A few recent additions, beyond polaraxes/polarplot which were introduced in R2016a and which @Walter Roberson mentions, may help with use cases like yours. Here is an example showing how to use compassplot (new in R2024b) to visualize vectors eminating from the origin, how to customize the PolarAxes to display only half of the circle, and how to use polarregion (R2024a) to highlight a specific area within the axes.
t = deg2rad(linspace(20, 160,10));
compassplot(t,10:-1:1,LineWidth=2);
thetalim([0 180]) % change theta limits show only 0-180 degrees
polarregion([pi/3 2*pi/3],[4 8],FaceColor="#06AF8F") % highlight a region of interest

Categories

Find more on Images in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!