How to read .csv files in MATLAB 2019a?

1 view (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 23 Dec 2019
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};

More Answers (0)

Community Treasure Hunt

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

Start Hunting!