Matlab square function Draw the face of a clock as shown below centered at the o
ID: 3731865 • Letter: M
Question
Matlab square function
Draw the face of a clock as shown below centered at the origin with a radius of 100 units. The size of the small red circles should be 10 units. The following functions will be helpful in MATLAB Cx,y]-pol2cart(theta, radius) rectangle(Position',[-5,-5,10,10],Facecolor', [100], ·Curvature', [1,1]) The first function converts polar coordinates to x-y coordinates The second function draws a 10 unit circle at the origin. You will need to experiment with the Position' arguments to understand how the location and offset work.Explanation / Answer
Code:
for k=0:11
[x,y] = pol2cart(k*pi/6,100);
rectangle( 'Position', [x-10,y-10,20,20], 'FaceColor',[1,0,0], 'Curvature', [1,1] );
end
daspect ([1,1,1]);
xlim( [-110,110] );
ylim( [-110, 110] );
Explanation:
k 0 1 2 3 4 5 6 7 8 9 10 11 theta 0 pi/6 2*pi/6 3*pi/6 4*pi/6 5*pi/6 pi 7*pi/6 8*pi/6 9*pi/6 10*pi/6 11*pi/6