How can I get select rows of a cell?

3 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2022-9-7
"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:

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by