generate coordinates circle,square,rectangle
显示 更早的评论
Hello,
I have to generate points(matrix),so that i have view the points as a circle(square,rectagle), when i display points(matrix) through plot.
Could someone help me?
Thanks.
采纳的回答
更多回答(1 个)
Giorgos Papakonstantinou
2014-3-2
% circle
r=1; % radius
C=[1 1];
theta=0:2*pi/360:2*pi; % the angle
m=r*[cos(theta')+C(1) sin(theta')+C(2)]; % the points you asked
plot(m(:,1), m(:,2))
axis equal
hold all
% Rectangle
a=1; % side a
b=.5; % side b
s=[0.5 0.75]; % bottom left start point
A=[s(1) s(1)+a s(1)+a s(1) s(1);s(2) s(2) s(2)+b s(2)+b s(2)];
plot(A(1,:), A(2,:))
axis equal
1 个评论
Will Reeves
2018-4-6
编辑:Will Reeves
2018-4-6
nice... although the "r*" shouldn't apply to the centre coordinate offset:
m=r*[cos(theta') sin(theta')] + C; % the points you asked
instead of this:
m=r*[cos(theta')+C(1) sin(theta')+C(2)]; % the points you asked
Or am I being silly?!
类别
在 帮助中心 和 File Exchange 中查找有关 Surfaces, Volumes, and Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!