How can I get select rows of a cell?

6 visualizzazioni (ultimi 30 giorni)
Corneel Lootens
Corneel Lootens il 7 Set 2022
Commentato: Stephen23 il 7 Set 2022
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 Commento
Stephen23
Stephen23 il 7 Set 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:

Accedi per commentare.

Risposta accettata

KSSV
KSSV il 7 Set 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

Più risposte (0)

Categorie

Scopri di più su Large Files and Big Data in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by