Importdata not importing as a cell array and instead as a column vector
이전 댓글 표시
Hi,
I have this input file as a .txt here
2
0.0 1.0 6.283185307
0.0 -1.0 -6.283185307
But when I use importdata, it gives me a line vector as stated:
data =
2.0000
0
1.0000
6.2832
0
-1.0000
-6.2832
I reckon it is due to the first line of the .txt file being a single integer. I can't change the contents of the .txt file.
Any idea how to fix this?
댓글 수: 1
dpb
2019년 9월 7일
Well, it depends on what you think is a valid "fix". You haven't specified what you would expect.
MATLAB can't store "jagged" arrays, so you'll have to do something about the fact there's only one element in the first record and three in the two other records (what about the rest of the file or is this all there is?).
Without more context of what the data are in terms of use/meaning, it's not easy to suggest the better of the various alternatives which could include the first record being a standalone variable on its own while the rest is a Nx3 array, or a cell array containing the one element as its first element and the array or ...
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!