Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Indexing

Subject: Indexing

From: rams

Date: 1 Oct, 2010 20:18:32

Message: 1 of 5

Hi,
I want to access only specified rows and all the columns in an excel. I tried the following code but got an error saying
??? Index exceeds matrix dimensions.
My code was

A=xlsread('example.xls');
X=A(980:1050,:);
Not sure if i can access specified rows like that.
example.xls file contains 1050 rows and 27 columns.

Subject: Indexing

From: Jan Simon

Date: 1 Oct, 2010 20:47:07

Message: 2 of 5

Dear rams,

Please check the size of A:
  A=xlsread('example.xls');
  size(A)
  % X=A(980:1050,:);

Kind regards, Jan

Subject: Indexing

From: Sean

Date: 1 Oct, 2010 20:47:08

Message: 3 of 5

rams <lramsb4u@gmail.com> wrote in message <1203005244.32811.1285964343010.JavaMail.root@gallium.mathforum.org>...
> Hi,
> I want to access only specified rows and all the columns in an excel. I tried the following code but got an error saying
> ??? Index exceeds matrix dimensions.
> My code was
>
> A=xlsread('example.xls');
> X=A(980:1050,:);
> Not sure if i can access specified rows like that.
> example.xls file contains 1050 rows and 27 columns.

Enter:
whos A
and see how big it is. It's not a full 1050 rows.

Subject: Indexing

From: ImageAnalyst

Date: 1 Oct, 2010 20:51:13

Message: 4 of 5

Try "end" instead of 1050:

X=A(980:end,:);

Subject: Indexing

From: Walter Roberson

Date: 1 Oct, 2010 20:55:15

Message: 5 of 5

On 10-10-01 03:47 PM, Sean wrote:
> rams <lramsb4u@gmail.com> wrote in message
> <1203005244.32811.1285964343010.JavaMail.root@gallium.mathforum.org>...

>> I want to access only specified rows and all the columns in an excel.
>> I tried the following code but got an error saying ??? Index exceeds
>> matrix dimensions.
>> My code was
>>
>> A=xlsread('example.xls');
>> X=A(980:1050,:);
>> Not sure if i can access specified rows like that.
>> example.xls file contains 1050 rows and 27 columns.
>
> Enter:
> whos A
> and see how big it is. It's not a full 1050 rows.

Random guess: the excel spreadsheet has a row which is column headers, and the
xlsread() has returned only the parts below that, leaving an array that ends
at row 1049 .

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us