Clear Filters
Clear Filters

How can I get select rows of a cell?

3 views (last 30 days)
I have a .txt file with some numbers in them Ax, Ay, Az, R, G, B, class but per row just 1 value.
Example:
1
5
3
100
150
200
1
When using c = textscan ('filename.txt', '%d');
It returns a cell?
I want to assign specific variable to a line but a cell doesn't work like an Array? I want to assign Ax to the first value in .txt file, Ay the second and so on.
Example: Ax = c{1,1}
Ay = c{2,1}
But it seems like with this code you can only select the whole column?
Thanks in advance!
  1 Comment
Stephen23
Stephen23 on 7 Sep 2022
"It returns a cell?"
Yes: in general one cell per format specifier. You specified one numeric format, so a scalar cell array is expected.
As far as I can see, there is nothing stopping you from using basic cell indexing to access the content of that cell array:

Sign in to comment.

Accepted Answer

KSSV
KSSV on 7 Sep 2022
If all you are numbers why don't use load, importdata, readtable.
Also in the textscan, you can get an array, read about cell2mat

More Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!