错误"索引超出Matrix尺寸" [英] Error " Index exceeds Matrix dimensions"

查看:88
本文介绍了错误"索引超出Matrix尺寸"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图读取一个由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,因此X62x2000矩阵.在clustergram中,属性RowLabelsColumnLabels的向量应该与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.

尝试删除RowLabelsColumnLabels以及其他属性.您仍然收到错误消息吗?

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

这篇关于错误"索引超出Matrix尺寸"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆