MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何在MATLAB中的6x6网格上绘制三角形? (https://www.labfans.com/bbs/showthread.php?t=22803)

poster 2019-12-10 16:49

如何在MATLAB中的6x6网格上绘制三角形?
 
我有一个文件[B]a.txt[/B]像这样:

0 0 0 3 4 3 0 0 3 0 3 4 0 1 0 4 4 4 0 1 3 1 3 5 0 2 0 5 4 5 0 3 0 0 4 0 这些是三角形的顶点[x1 y1 x2 y2 x3 y3],需要在6x6的网格上绘制。我需要在单个图形上看到这些三角形。

如何在MATLAB中完成?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~非常感谢大家!

终于成功了:

a = dlmread('a.txt'); clf xlim([0 6]) ylim([0 6]) for i = 1:size(a,1) line(a(i,[1:2:5,1]), a(i,[2:2:6,2]), 'color',rand(1,3)) pause; end grid on;
回答:
a = dlmread('a.txt') clf for i = 1:size(a,1) line(a(i,[1:2:5,1]), a(i,[2:2:6,2]), 'color',rand(1,3)) end 请注意,我重复顶点以完成三角形,并且每次循环都使用随机颜色。

因为格式简单,所以我可以将DLMREAD与默认值一起使用。



[url=https://stackoverflow.com/questions/1506243]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 01:01

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.