Hey guys,
I need to generate polar coordinates and create this 'sensor beam' that would cover 0 to 180 degrees by 5 degree increase with values varying of (0.0x to 0.x). which means there is ~37 values.

댓글 수: 6

Rik
Rik 2018년 8월 16일
Sounds like a fun project. What is your question?
Have a read here (and here). It will greatly improve your chances of getting an answer.
My question is clear. I am asking how to generate a polar plot that would only cover 0 to 180 degrees. The values for this plot would be starting at 0, and going up by 5 degrees up to 180. I have an array of values that would be used for it, therefore it won't be random.
So like this?
theta=0:5:180;
rho=rand(size(theta))/10;
polarplot(theta,rho)
Correct, but this far I managed to get on my own. Now what I need is to use my data of 37 values to get something like this on a polar coordinates (see picture attached). I couldn't figure this out, how exactly to plot these values so that I jump by 5 degrees. I need a proper way to use my array.
Rik
Rik 2018년 8월 16일
You should provide a clear description of your inputs and the intended output. My code shows you how to have 5 degree jumps. How doesn't that work for you? What code are you trying to apply it to your data? What errors are you getting?
Your code does what I need, but now imagine you have exactly 37 values (no more no less) and you want to plot a sort of beam of these values covering 0 to 180 degrees on a polar plot. At degree 0 you have value 1, at degree 5 you have value 2,...at degree 180 you have value 37. They will form a beam as the values will grow towards 90 degrees and drop after. All i want to do is to plot those values at exactly 5 degree intervals. Does it make sense?

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

 채택된 답변

Rik
Rik 2018년 8월 16일

0 개 추천

Today's lesson: never assume, but RTM. Because you mentioned 180 degrees, I assumed you had checked the doc to see if Matlab uses radians of degrees. I also assumed that my code would work, as it was only a 3 line example.
It turns out both assumptions were incorrect. The polarplot function uses radian, so my code example actually inputs 28.6 revolutions instead of 180 degrees. You can fix this by using the deg2rad function (which avoids typos), or use a manual conversion factor (so deg*pi/180).
This code should actually do what you mean.
rho=rand(size(theta))/10;
theta=0:5:180;%or theta=linspace(0,180,numel(rho));
figure(1),clf(1)
polarplot(deg2rad(theta),rho)

추가 답변 (0개)

카테고리

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

태그

질문:

2018년 8월 16일

댓글:

2018년 8월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by