load txt file in matrix into matlab
古いコメントを表示
how to load this into matlab from a txt file:
[1 2 1 E A Iy Iz Ix J
2 3 2 E A Iy Iz Ix J
3 4 3 E A Iy Iz Ix J]
the problem is that the letters E A Iy Iz Ix J ----> gives NaN when I load it into matlab
6 件のコメント
madhan ravi
2020 年 6 月 2 日
Attach the text file.
KSSV
2020 年 6 月 2 日
Read about textscan.
polo Mahmoud
2020 年 6 月 2 日
Rik
2020 年 6 月 2 日
Do you only want to store the numbers? Or should the letters be replaced by something?
madhan ravi
2020 年 6 月 2 日
Rik probably he would need the letters for his symbolic computations. So the solution is to use textscan(...) as KSSV suggested.
polo Mahmoud
2020 年 6 月 2 日
採用された回答
その他の回答 (1 件)
Ameer Hamza
2020 年 6 月 2 日
As Madhan mentioned that you might want to load it as symbolic, you may try
str = fileread('test.txt');
words = regexp(str, '\w+', 'match');
idx = cellfun(@(x) isnan(str2double(x)), words);
syms(words(idx));
M = eval(str);
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!