简体   繁体   English

错误“索引超出矩阵尺寸”

[英]Error “ Index exceeds Matrix dimensions”

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. 我正在尝试读取一个由62列和2000行组成的Excel 2003文件,然后从2类数据的2000年模式中绘制2D树状图,作为我在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 我的数据在这里: http : //rapidshare.com/files/383549074/data.xls

Please delete the 2001 column if you want to use the data for testing. 如果要使用数据进行测试,请删除2001列。

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})

After the xlsread statement you should get a 2000x62 double matrix Data . xlsread语句之后,您应该获得2000x62 double矩阵Data Then you transpose it and assign to X , so X is 62x2000 matrix. 然后将其转置并分配给X ,因此X62x2000矩阵。 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 . 在属性的RowLabels ColumnLabels中,应该将RowLabelsclustergram向量与您的Data的大小匹配,但是您将传递2000长度的向量作为RowLabels ,将2长度的向量传递给ColumnLabels This might cause the error. 这可能会导致错误。

What version of MATLAB are you using? 您正在使用什么版本的MATLAB? It looks like pretty old, since you have clustergram as function, but in later versions of Bioinformatic Toolbox it was redesigned as object. 它看起来很老,因为您具有clustergram功能,但是在更高版本的Bioinformatic Toolbox中,它已重新设计为对象。 In R2010a your code would generate 在R2010a中,您的代码将生成

" ROWLABELS size does not match data" ROWLABELS大小与数据不匹配”

but I'm not sure what it would be in old version. 但我不确定旧版本会是什么。

Try to remove RowLabels and ColumnLabels , as well as other properties. 尝试删除RowLabelsColumnLabels以及其他属性。 Do you still get the error? 您是否仍然收到错误?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM