MATLAB: How to draw a figure..

Hi everyone
I was wondering how to draw a star's outline using 23 points, so that 13 of them are closer to begining of coordinate system and other 13 further
To start with, my idea is to set 2 points – one closer and second further and then mark the rest using that 2 points from begining but moving an angle.
So i declared matrix full of "0" and then i would like to place all the matrix points on the graph by using for ex. the rotation matrix y = A * X where A = [cos (theta),-sin (theta) sin (theta) cos (theta )], and connect the dots as vectors using plot command. But im quite beginner in Matlab and i have no idea how to put my ideas on code.
I deduced something like that:
M=zeros(2,26)
...
for K=2:2:13
M(:,k)=0,5*A*M(:,k-1) %Point 2
M(:,k+1)=2*A(M(:,k) %Point 3 using Point 2 etc.
plot(...)
...
end
How to obtain the desired effect? Is that even possible? :/
I would be very grateful for solution. Thanks in advance

Best Answer

This seems to do what you want. Change (pi/13) to (pi/12) to get a symmetrical version the figure you drew, since it’s not symmetrical and there are more points with (y<0) than (y>0). This isn’t exactly what you drew, but it’s close:
th = 0:(pi/13):(2*pi);
rv = [1.0; 0.5];
for k1 = 1:length(th)
r = rv(rem(k1,2)+1); % Choose ‘rv(2)’ for even ‘k1’, ‘rv(1)’ for odd ‘k1’
[x(k1),y(k1)] = pol2cart(th(k1),r);
end
figure(1)
plot(x,y)
axis equal
Change the values in the rv vector and the (pi/13) interval to change the appearance of the star. See the pol2cart. documentation for details.
This was fun! I’d never considered that possibility.