错误”索引超过矩阵维度”
我正在尝试读取一个由 62 列和 2000 行组成的 excel 2003 文件,然后从 2 个数据类别的 2000 个模式中绘制 2d 树形图作为我在 matlab 中的绘图。当我运行脚本时,它给出了上述错误。我不知道为什么。有人知道为什么我会出现上述错误吗?
我的数据在这里: http://rapidshare.com/files/383549074/data.xls
请删除如果要使用2001列的数据进行测试。
我的代码在这里:
% Script file: cluster_2d_data.m
d=2000; n1=22; n2=40; N=62
Data=xlsread('data.xls','A1:BJ2000');
X=Data';
R=1:2000;
C=1:2;
clustergram(X,'Pdist','euclidean','Linkage','complete','Dimension',2,...
'ROWLABELS',R,'COLUMNLABELS',C,'Dendrogram',{'color',5})
I am trying to read an excel 2003 file which consist of 62 columns and 2000 rows and then draw 2d dendrogram from 2000 pattern of 2 categories of a data as my plot in matlab. When I run the script, it gives me the above error. I don't know why. Anybody has any idea why I have the above error?
My data is here:
http://rapidshare.com/files/383549074/data.xls
Please delete the 2001 column if you want to use the data for testing.
and my code is here:
% Script file: cluster_2d_data.m
d=2000; n1=22; n2=40; N=62
Data=xlsread('data.xls','A1:BJ2000');
X=Data';
R=1:2000;
C=1:2;
clustergram(X,'Pdist','euclidean','Linkage','complete','Dimension',2,...
'ROWLABELS',R,'COLUMNLABELS',C,'Dendrogram',{'color',5})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
xlsread
语句之后,您应该得到一个2000x62 double
矩阵Data
。然后将其转置并分配给X
,因此X
是62x2000
矩阵。在clustergram
中,属性RowLabels
和ColumnLabels
的向量应该与您的Data
的大小相匹配,但是您将 2000 长度的向量作为RowLabels
传递,将 2 长度的向量作为ColumnLabels
传递。这可能会导致错误。您使用什么版本的 MATLAB?它看起来很旧,因为您将 clustergram 作为函数,但在 Bioinformatic Toolbox 的更高版本中,它被重新设计为对象。在 R2010a 中,您的代码将生成
但我不确定旧版本中的情况。
尝试删除
RowLabels
和ColumnLabels
以及其他属性。您仍然收到错误吗?After the
xlsread
statement you should get a2000x62 double
matrixData
. Then you transpose it and assign toX
, soX
is62x2000
matrix. In theclustergram
vectors for the propertiesRowLabels
andColumnLabels
are supposed to match the size of yourData
, but you pass a 2000-length vector asRowLabels
and 2-length vector asColumnLabels
. This might cause the error.What version of MATLAB are you using? It looks like pretty old, since you have
clustergram
as function, but in later versions of Bioinformatic Toolbox it was redesigned as object. In R2010a your code would generatebut I'm not sure what it would be in old version.
Try to remove
RowLabels
andColumnLabels
, as well as other properties. Do you still get the error?