【发布时间】:2023-03-05 12:04:01
【问题描述】:
我有一个文本文件(“coordinates.txt”),其中包含点的 x 和 y 坐标。 文件如下所示:
11 44 2 9
11 44 5 8
2 1 6 11
2 1 10 3
我需要在 (11, 44) 到 (2, 9)、(11, 44) 到 (5, 8)、(2, 1) 到 (6, 11) 和 (2, 1) 之间画线) 到 (10, 3)。
我可以手动做到这一点:
x = [11 11 2 1; 2, 5, 6, 10];
y = [44 44 1 1; 9 8 11 3];
plot (x, y).
但实际文件很长,我需要“自动化”这个过程。
我试过了:
load coordinates.txt;
edit coordinates.txt;
x1= [coordinates(:, 1); coordinates(:, 3)];
y1 = [coordinates(:, 2); coordinates(:, 4)];
plot (x1, y1).
它给了我从 (11, 44) 到 (2, 9), (2, 9) 到 (5, 8), (5, 8) 到 (6, 11), (6, 11) 的线到 (10, 3)。
有人可以帮忙吗?
【问题讨论】:
标签: matlab text draw lines points