How to read .csv files in MATLAB 2019a?

2 次查看(过去 30 天)
Sorry,
I have a problem with a command. In Matlab version 2015a I used to use commands
filename1= 'B_STAT.xlsx'
[d1,tex]= xlsread(filename1);
REAL_B=d1(:,3);
REAL_B=d1(:,4);
in order to open a file and separate columns. In 2019a version I am not allowded to use these commands: In command window shows me that : "Error in line 2"
Could someone help me in order to fix my problem?

采纳的回答

Walter Roberson
Walter Roberson 2019-12-23
Those are still valid commands in MATLAB.
However if you do not happen to be using MS Windows with Excel installed, then you would get a warning that "Basic" mode would be used, and it would try to find B_STAT.csv which probably does not exist.
You can use
d1 = readtable(filename1);
to do the reading. You might need
d1 = readtable(filename1, 'readvariablenames', false);
The result either way would be a table() object, and then
REAL_B = d1{:,3};

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Files and Folders 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by