开发者

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. 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 t开发者_Go百科o 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})


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.

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 size does not match data"

but I'm not sure what it would be in old version.

Try to remove RowLabels and ColumnLabels, as well as other properties. Do you still get the error?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜