polar plot to create circular shape with varying radius

조회 수: 11 (최근 30일)
William Gray
William Gray 2019년 7월 19일
댓글: Star Strider 2019년 7월 19일
Hi Everyone,
I'm new to polar plotting and I'm struggling to sucesfully plot what I'm after.
I want to polar plot a random variable around an origin of my choice. I have tried to do this through the following code:
k = round(rand(1,50)*10)+10;
Th = linspace(0,2*pi,50);
Rho = k.*sin(Th);
figure
polar(Th,Rho)
However, this isn't quite working. As all the values are positive it's cramping the plot in the top 2 quadrants. Please see attached plot for what I mean. I have sketched the kind of plot I am after (apologies for how rough this sketch is) but any ideas would be realy appreciated.
Thanks everyone!

채택된 답변

Star Strider
Star Strider 2019년 7월 19일
Plotting the sine function in a polar plot will produce one circle in the upper half of the polar axes.
To get the sort of plot you want, do this:
figure
polar(Th,k)
  댓글 수: 2
William Gray
William Gray 2019년 7월 19일
Hi,
Thank you for this, a simple change but it gives me exactly what I was after!
Star Strider
Star Strider 2019년 7월 19일
As always, my pleasure!

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

추가 답변 (1개)

infinity
infinity 2019년 7월 19일
Hello,
How about if you change a bit like this
clear
close all
% k = round(rand(1,50)*10)+10;
k = round(rand(1,50));
Th = linspace(0,2*pi,50);
% Rho = k.*sin(Th);
Rho = k.*sin(Th)-10;
figure
polar(Th,Rho)
  댓글 수: 1
William Gray
William Gray 2019년 7월 19일
Hi,
Thanks for the answer this helps! Ive found from the script however that the 'randomness' of the values appear slightly stunted, I think because the rounding of k just gives zero's and ones. I've managed to plot what I was after below with Star Strider's answer but again, thank you for the help.

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

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by