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

Walter Roberson
Walter Roberson 2018년 6월 9일
Are you asking how to restrict the graphic output of compass() to a particular range of angles ?
Ahmed Siddig
Ahmed Siddig 2018년 6월 9일
yes please

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 9일

1 개 추천

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

Here is a hack you can use, provided that you do not mind having the current axes deleted. Put the following polar.m in the directory that is active when you are running compass(). Or better yet, put it on the end of the same file that you are invoking compass() from that you want to be able to limit the angular range, so that it cannot interfere with anything else.
To use, call compass() as you normally would, and then
set(gca, 'ThetaLim', [225, 315])
Ahmed Siddig
Ahmed Siddig 2018년 6월 9일
Amazing work thank you very much but the thing is i want it to plot the reading in the specific region even if its not in that region for example if the reading point to 30 degrees in the default compass i want it in our situation to plot it in let say 255 degrees some thing like that. thank you again.
Walter Roberson
Walter Roberson 2018년 6월 10일
What value should it be plotted at? Where should it point? With what value?
I think I need a diagram showing the original compass() image and what you would like the new version to look like.
Ahmed Siddig
Ahmed Siddig 2018년 6월 10일
OK, so suppose i have x=(4+90i) and i plot it in compass i will have (capture) and i want to plot it in (225,315) region to get something like this (2) i was only able to do so by making x=(-4-90i) do you know any other way? thank you
Ahmed Siddig
Ahmed Siddig 2018년 6월 10일
May be something like user-input to specify region of plotting e.x if i pressed 1 it limits the reading in (45,135), 2 limits it in (135,225) up until 45 degrees again.
Walter Roberson
Walter Roberson 2018년 6월 13일
Sorry, I do not understand where the points should be moved to, or what angle they should end up pointing.
Ahmed Siddig
Ahmed Siddig 2018년 6월 14일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Abby Skofield
Abby Skofield 2024년 10월 4일

2 개 추천

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

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2018년 6월 9일

답변:

2024년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by