How can I convert cell contents to a matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to import text files, and convert it's data into a matrix. When I import the file, it stores it as a 50x1 cell, how can I convert this to a 50x9 or 50x10 matrix, where I can reference each aspect of the file individually?
fid = fopen ('40_8deg_HL_Both.txt', 'r');
data = textscan(fid, '%s', 'HeaderLines', 9, 'delimiter', '/n');
fclose (fid);
mat = data{:};
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/209549/image.png)
3 件のコメント
Stephen23
2019 年 3 月 21 日
@Jacob Lobao: please upload a sample file by clicking the paperclip button.
採用された回答
Andrei Bobrov
2019 年 3 月 21 日
編集済み: Andrei Bobrov
2019 年 3 月 21 日
T = readtable('40_8deg_HL_Both.txt','ReadVariableNames',false,...
'Format','%{yyyyMMdd hh:mm:ss.SSS}D %f %f %f %f %f %f %f %q',...
'HeaderLines',9);
and please attach your txt-file.
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!