user8357
user8357

Reputation: 29

What is the best way to load an Excel file in MATLAB to use as a matrix?

I placed the file in my current folder and the syntax I use to load the file is as follows. The file name is marksdata:

xlsread('marksdata.xlsx');
A='marksdata';

This file contains a spreadsheet which I must use as a matrix. For some reason, every time I try to use the data in the file, an error is returned:

Index exceeds matrix dimensions.

However, the index value that I'm using is within the limits of the spreadsheet, so is the file not loading into my script all together? If so, what would the correct syntax be to load an Excel file as a matrix?

Upvotes: 0

Views: 73

Answers (1)

LaszloLadanyi
LaszloLadanyi

Reputation: 973

What you do here is that you read in the spreadsheet with one command, but do not assign its content to any variable. Then you assign the string 'marksdata' to A (which matlab interprets as an array of characters). Try A=xlsread('marksdata.xlsx');.

Upvotes: 2

Related Questions