How do I import .csv file into MATLAB that has multiple values per field? MATLAB is not importing this properly.

1 visualización (últimos 30 días)
So I have a .csv file, that has 14 rows and 120 columns. I need to import this .csv file into MATLAB. Now the problem is that there are 128 values per each field in this .csv file, all of which has to be imported properly (I'm attaching picture of how the data looks here below, you can see there are multiple values per field). I tried importing it as a .csv but it doesn't give me any of these values. I also tried converting to .txt and importing that, but it doesn't give all the values either. Is there any way I could import this data properly into MATLAB?

Respuestas (1)

Walter Roberson
Walter Roberson el 10 de Nov. de 2020
S = fileread('YourFileNameHere.csv');
S = regexrep(S, {'\[|\]', '\s+'}, {'', ','});
data = cell2mat(textscan(S, '')); %format '' tells it to figure out number of columns

Community Treasure Hunt

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

Start Hunting!

Translated by