Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在matlab中,如何从文件中读取空格分隔的两列整数数据?_Matlab_Plot_Octave - Fatal编程技术网

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

在matlab中,如何从文件中读取空格分隔的两列整数数据?,matlab,plot,octave,Matlab,Plot,Octave,例如,我有一个类似这样的文件dog_test.txt(长度接近10000) 我想看看索引的分布以及1,-1的值。(两个值作为(x,y)点。)。所以我做了 M = dlmread('dog_test.txt'); M1=M; M1(:,2)=[]; M2=M;M2(:,1)=[]; plot(M1,M2); 并且可以看到 我不太精通matlab,所以我认为应该可以直接从m中绘制绘图。我怎么做?看起来您已经进行了大量测试,并得到了分类结果(-1或+1),对吗?在这种情况下,更好的图可能是茎图。e

例如,我有一个类似这样的文件dog_test.txt(长度接近10000)

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

M = dlmread('dog_test.txt');
M1=M; M1(:,2)=[];
M2=M;M2(:,1)=[];
plot(M1,M2);
并且可以看到


我不太精通matlab,所以我认为应该可以直接从m中绘制绘图。我怎么做?

看起来您已经进行了大量测试,并得到了分类结果(-1或+1),对吗?在这种情况下,更好的图可能是茎图。e、 g

X = 1 : 50; Y = [-1,1]; Y = Y(randi([1,2], 1, 50)); % create random dataset

stem (X, Y,                       ...  % "..." allows you to continue below
      'linestyle', '--',          ...  % dotted lines
      'linewidth', 3,             ...  % width of '2'
      'color', 'k',               ...  % black color lines
      'markeredgecolor', 'r',     ...  % red outline for markers
      'markerfacecolor', 'green', ...  % green 'filling' for markers
      'markersize',15);                % bigger markers

axis([0,50,-1.5,1.5]);                 % adjust axis limits

(因此,就你而言:)


plot(M(:,2),M(:,1))
?plot在我看来很好。@gameoftrows:看一下他的代码,他想要
plot(M(:,1),M(:,2))
@Andy啊,是的,我错了。啊,plot(M(:,1),M(:,2))做到了。(我试过类似的方法,但有错误。)谢谢!
X = 1 : 50; Y = [-1,1]; Y = Y(randi([1,2], 1, 50)); % create random dataset

stem (X, Y,                       ...  % "..." allows you to continue below
      'linestyle', '--',          ...  % dotted lines
      'linewidth', 3,             ...  % width of '2'
      'color', 'k',               ...  % black color lines
      'markeredgecolor', 'r',     ...  % red outline for markers
      'markerfacecolor', 'green', ...  % green 'filling' for markers
      'markersize',15);                % bigger markers

axis([0,50,-1.5,1.5]);                 % adjust axis limits
stem (M(:, 1), M(:, 2));