How do I parse this given data in matlab
1 回表示 (過去 30 日間)
古いコメントを表示
Sucharitha Chokkappa Gari
2020 年 10 月 8 日
回答済み: Walter Roberson
2020 年 10 月 8 日
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/374696/image.jpeg)
2 件のコメント
Mathieu NOE
2020 年 10 月 8 日
hi
are you getting this by reading a txt / ascii file ? there are plenty of possibilities to red such files with matlab
how do you get this data ?
in worst case , you 'll end up to write directly data names and values either one by one or in a more structured way (cells, arrays)
read matlab help
have a look at
採用された回答
Walter Roberson
2020 年 10 月 8 日
S = fileread('YourFileNameGoesHere.txt');
colon_matches = regexp(S, '^.*:\s*(?<v1>\S+)\s*(?<v2>\S+)', 'dotexceptnewline', 'lineanchors');
v1 = str2double({colon_matches.v1});
v2 = str2double({colon_matches.v2});
power_matches = regexp(S, '^\w+\s+(?<power>)', 'lineanchors');
p = str2double({power_matches.power});
header_vals = [v1(:), v2(:)];
power_vals = p(:);
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!