load txt file in matrix into matlab
조회 수: 1 (최근 30일)
이전 댓글 표시
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일
Rik probably he would need the letters for his symbolic computations. So the solution is to use textscan(...) as KSSV suggested.
채택된 답변
Anish Walia
2020년 6월 2일
Since the data type of all values is not same, try importing it as cell array
data = readcell('testload.txt')
추가 답변 (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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!