我正在尝试使用matlab绘制一个形状。在这里我需要加入弧线。我使用以下代码创建了弧
circr = @(radius,rad_ang) [radius*cos(rad_ang); radius*sin(rad_ang)]; % Circle Function For Angles In Radians
N = 25; % Number Of Points In Complete Circle
r_angl = linspace(pi/2, 5*pi/4, N); % Angle Defining Arc Segment (radians)
radius = 0.5; % Arc Radius
xy_r = circr(radius,r_angl); % Matrix (2xN) Of (x,y) Coordinates
figure(1)
plot(xy_r(1,:), xy_r(2,:))
axis([-1.25*radius 1.25*radius 0 1.25*radius])
代码生成以下输出
现在我修改了代码以绘制其他弧
circr = @(radius,rad_ang) [radius*cos(rad_ang); radius*sin(rad_ang)]; % Circle Function For Angles In Radians
N = 25; % Number Of Points In Complete Circle
r_angl = linspace(pi/2, 5*pi/4, N); % Angle Defining Arc Segment (radians)
radius = 0.5; % Arc Radius
xy_r = circr(radius,r_angl); % Matrix (2xN) Of (x,y) Coordinates
r_angl1 = linspace(4*pi/4,pi/4); % Angle Defining Arc Segment (radians)
radius1 = 0.1; % Arc Radius
xy_r1 = circr(radius1,r_angl1); % Matrix (2xN) Of (x,y) Coordinates
figure(1)
plot(xy_r(1,:), xy_r(2,:),xy_r1(2,:),xy_r1(1,:))
axis([-1.25*radius 1.25*radius 0 1.25*radius]) % Set Axis Limits
axis equal
我如何加入两个弧线?我需要使用他们的终点加入他们
答案 0 :(得分:-1)
插入以下行将使用行
连接端点hold on;
line([xy_r(1,1) xy_r1(1,end)], [xy_r(2,1) xy_r1(2,end)]);
line([xy_r(1,end) xy_r1(2,1)], [xy_r(2,end) xy_r1(1,1)]);
合:
figure(1)
plot(xy_r(1,:), xy_r(2,:),xy_r1(2,:),xy_r1(1,:))
hold on;
line([xy_r(1,1) xy_r1(1,end)], [xy_r(2,1) xy_r1(2,end)]);
line([xy_r(1,end) xy_r1(2,1)], [xy_r(2,end) xy_r1(1,1)]);
axis([-1.25*radius 1.25*radius 0 1.25*radius]) % Set Axis Limits
axis equal