Importdata not importing as a cell array and instead as a column vector
Show older comments
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 Comment
dpb
on 7 Sep 2019
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 ...
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!