How do I import .csv file into MATLAB that has multiple values per field? MATLAB is not importing this properly.
2 ビュー (過去 30 日間)
古いコメントを表示
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?

2 件のコメント
Stephen23
2020 年 11 月 16 日
@Zuha Yousuf : please upload a sample file by clicking on the paperclip button.
回答 (1 件)
Walter Roberson
2020 年 11 月 10 日
S = fileread('YourFileNameHere.csv');
S = regexrep(S, {'\[|\]', '\s+'}, {'', ','});
data = cell2mat(textscan(S, '')); %format '' tells it to figure out number of columns
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!