Using the load command to import data into matlab

Hey everyone,
I'm a new user to MATLAB and I'm already having trouble in importing data into MATLAB. I have an excel file, or spreadsheet, that I want to import into a variable into MATLAB. I've tried using the load and import function but I keep getting errors such as 'unknown text in line 1' or 'uninterpretable data'. Could I please get help in how I can make it work?
Thanks

 採用された回答

Walter Roberson
Walter Roberson 2016 年 9 月 25 日

0 投票

Use xlsread() or readtable() for spreadsheets.

5 件のコメント

Diego Espinosa
Diego Espinosa 2016 年 9 月 25 日
The xlsread() was able to accept it but it couldn't be saved into a variable.
Thanks anyway
Stephen23
Stephen23 2016 年 9 月 25 日
編集済み: Stephen23 2016 年 9 月 25 日
"The xlsread() was able to accept it but it couldn't be saved into a variable."
How do you know that? Were you were calling it correctly? If you actually gave us details of what you are doing then we could actually help you. You claim that you are "a new user to MATLAB", but now you apparently know exactly what MATLAB can and cannot do.
Make a new comment: show us the code that you are trying and upload a sample file for us to try out.
Walter Roberson
Walter Roberson 2016 年 9 月 25 日
[num, txt, raw] = xlsread('TheFileName.xls');
num would then be just the numeric portion; txt would be the text headers; raw would be a cell array combining the two in proper position.
Diego Espinosa
Diego Espinosa 2016 年 9 月 25 日
I'm still receiving the same type of error about "unknown text on line 1"
So far I haven't started in any other form of code. I've only been trying to import an excel spreadsheet and save it to a variable
A = xlsread('filename.xls.')
[num, txt, raw] = xlsread('filename.xls');
It has been able to accept it because its shown in the workspace but there isn't any data displayed, it counts it as empty.
Stephen23
Stephen23 2016 年 9 月 25 日
編集済み: Stephen23 2016 年 9 月 25 日
@Diego Espinosa: please make a new comment and tell us:
  1. Which MATLAB version you are using.
  2. What operating system you are using.
  3. Whether you have MS Office installed.
  4. The complete error message (all of the red text).
  5. And upload a sample data file for us (click the paperclip button).

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by