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!