MATLAB Help reading an Excel file with Matlab

AI Thread Summary
The discussion revolves around using the readtable command in MATLAB to import data from an Excel file. A user encounters an error indicating that the readtable function is undefined, which is due to their version of MATLAB being r2010b. The readtable function is only available in MATLAB version r2013b and later. Users suggest alternatives, including using the xlsread function, which is compatible with earlier versions, or csvread for text files. Additionally, if the user has the Statistics Toolbox, they can utilize a dataset array, which is similar to a table but not as advanced as the newer table data type introduced in r2013b.
quantumspark
Messages
2
Reaction score
0
Hi everyone, this is my first post on the physics forums. I am trying to use the readtable command in Matlab to make a table from an Excel file. Matlab is still new to me so I'm running into problems a lot. When I input T = readtable('myfile.txt'), I get an error that says "? Undefined function or method 'readtable' for input arguments of type 'char'." Can anybody tell me what to do differently? I followed the Matlab instructions to the tee.
 
Physics news on Phys.org
Oh, looks like I have the r2010b version. So I guess it only works in the latest version?
 
quantumspark said:
Oh, looks like I have the r2010b version. So I guess it only works in the latest version?

if you poke around google there may be some user code to do it.

Did you try the xlsread function? it appears to be in earlier releases. Just change the name from readtable to xlsread.
 
If you have a text file csvread will work too.
 
Tables and categorical arrays are new for R2013b, so you won't be able to use them in older versions even if you use a legacy import function.

There is a catch though, if you have Statistics Toolbox. If so, you can use a dataset array from the toolbox (very similar to a table).
 

Similar threads

Replies
3
Views
2K
Replies
4
Views
1K
Replies
18
Views
6K
Replies
9
Views
3K
Replies
4
Views
6K
Replies
2
Views
2K
Replies
7
Views
8K
Back
Top