我有一个 pts 带有2D点(x,y)的文件,看起来像这样:

version: 1
n_points: 5
{
159.128 108.541
230.854 109.176
164.841 179.633
193.404 193.597
192.769 229.143
}

如何读取此文件并将这些数据导入MATLAB中的变量?

谢谢。

有帮助吗?

解决方案

我会那样做

 FileId=fopen(Filename)
 npoints=textscan(FileId,'%s %f',1,'HeaderLines',1)

 points=textscan(FileId,'%f %f',npoints{2},'MultipleDelimsAsOne',1,'Headerlines',1)
 % now you have the values you want you can put them in a matrix or any variable
 Y=cell2mat(C);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top