在matlab中,如何从文件中读取空格分隔的两列整数数据?

时间:2016-08-15 12:37:40

标签: matlab plot octave

例如,我有一个像这样的文件dog_test.txt(长度接近10,000)。

000001  1
000002 -1
000003 -1
000004 -1
000006 -1
000008 -1
000010 -1
000011 -1
000013 -1
000014 -1
000015 -1
000018  1
000022 -1
000025 -1
...

我希望看到索引的分布以及1,-1值。 (两个值为(x,y)点。)。所以我做了

M = dlmread('dog_test.txt');
M1=M; M1(:,2)=[];
M2=M;M2(:,1)=[];
plot(M1,M2);

并且可以看到 enter image description here

我不熟悉matlab,所以我认为应该可以直接从M.绘制情节。我该怎么做?

1 个答案:

答案 0 :(得分:2)

看起来你有很多测试和分类结果(-1或+1),对吗?在这种情况下,更好的情节可能是干线图。 e.g

stem (M(:, 1), M(:, 2)); 

enter image description here

(所以,在你的情况下:)

{{1}}
相关问题