MATLAB Answers

How can I change the code to get this plot?

6 views (last 30 days)
Bassa__
Bassa__ on 21 Sep 2020
Edited: Adam Danz on 21 Sep 2020
So i got this code:
phi = (sqrt(5)+1)/2;
golden_angle = 2*pi/phi;
max_angle = 10000;
theta = 1:golden_angle:max_angle;
r = sqrt(theta);% radio
[x,y] = pol2cart(theta,r);% this is unnecesary (polarplot f) but i like to do it
plot(x,y,'.','MarkerSize',10);axis off;
from the code you get the (a) plot and I need to get (b) modifying the code.
I tried using scatter (and plotscatter)
A=linspace(300,1,2575);
polarscatter(theta,r,A,'.','b');
but it isnt the same. help pls

  0 Comments

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 21 Sep 2020
Edited: Adam Danz on 21 Sep 2020
Key points.
  1. Use scatter() instead of plot() so you can control individual marker size.
  2. Scale the radii values ('r') to a range of marker sizes defined in 'markerSz'. Play around with that variable to get the range of marker sizes you want.
phi = (sqrt(5)+1)/2;
golden_angle = 2*pi/phi;
max_angle = 10000;
theta = 1:golden_angle:max_angle;
r = sqrt(theta);% radio
[x,y] = pol2cart(theta,r);% this is unnecesary (polarplot f) but i like to do it
% rescale r value to max and min marker size range
markerSz = [1, 25]; % [min, max] marker size; play around with it.
msize = (r-min(r))/range(r)*range(markerSz)+markerSz(1);
subplot(1,2,1)
scatter(x,y,max(msize),'b','filled','Marker', 'o')
axis equal
axis off
subplot(1,2,2)
scatter(x,y,msize,'b','filled','Marker', 'o')
axis equal
axis off
linkaxes()

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!