错误"索引超出Matrix尺寸" [英] Error " Index exceeds Matrix dimensions"
问题描述
我试图读取一个由62列和2000行组成的Excel 2003文件,然后从2类数据的2000年模式中绘制2D树状图,作为我在Matlab中的绘图.当我运行脚本时,它给了我上面的错误.我不知道为什么有人知道为什么我会出现上述错误吗?
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?
我的数据在这里: http://rapidshare.com/files/383549074/data.xls
如果要使用数据进行测试,请删除2001列.
Please delete the 2001 column if you want to use the data for testing.
我的代码在这里:
% 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})
推荐答案
在xlsread
语句之后,您应该获得一个2000x62 double
矩阵Data
.然后将其转置并分配给X
,因此X
是62x2000
矩阵.在clustergram
中,属性RowLabels
和ColumnLabels
的向量应该与Data
的大小匹配,但是您将2000长度的向量作为RowLabels
传递,将2长度的向量作为ColumnLabels
传递.这可能会导致错误.
After the xlsread
statement you should get a 2000x62 double
matrix Data
. Then you transpose it and assign to X
, so X
is 62x2000
matrix. In the clustergram
vectors for the properties RowLabels
and ColumnLabels
are supposed to match the size of your Data
, but you pass a 2000-length vector as RowLabels
and 2-length vector as ColumnLabels
. This might cause the error.
您使用的是哪个版本的MATLAB?由于您具有clustergram
作为功能,因此它看起来很旧,但是在更高版本的Bioinformatic Toolbox中,它已重新设计为对象.在R2010a中,您的代码将生成
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 generate
"
ROWLABELS
大小与数据不匹配"
"
ROWLABELS
size does not match data"
但我不确定旧版本中会是什么.
but I'm not sure what it would be in old version.
尝试删除RowLabels
和ColumnLabels
以及其他属性.您仍然收到错误消息吗?
Try to remove RowLabels
and ColumnLabels
, as well as other properties. Do you still get the error?
这篇关于错误"索引超出Matrix尺寸"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!