Access data from table element

1 view (last 30 days)
Giulia Panusa
Giulia Panusa on 9 Dec 2021
Commented: Giulia Panusa on 10 Dec 2021
I would like to extrapolate a specific number from a table element, namely the thir one in thi case. The routine that reads .txt files is:
for n=1:numfiles
c{n} = readtable(s(n).name);
a = file_list(n);
RMS_spot_radius=c{1};
T=RMS_spot_radius;
T_=T(5,1)
end
For each file it returns:
T= Title
__________________________________________________________________________________________________________________________
{'0.55000000 - 0.55000000 →0.00006669 →0.00013316 →1.08604530 →0.76784704 →0.76805294'}
How do I access only the third number here?
Thank you!
  2 Comments

Sign in to comment.

Answers (1)

Mathieu NOE
Mathieu NOE on 9 Dec 2021
Edited: Mathieu NOE on 9 Dec 2021
hello Giulia
try this
clc
clearvars
s = dir('00*.txt')
numfiles = numel(s);
for n=1:numfiles
filename = s(n).name;
T = readtable(s(n).name,'headerlines',9);
% a = file_list(n); % could not run this code
RMS_spot_radius(n,1) = T.Radius;
end
  3 Comments
Giulia Panusa
Giulia Panusa on 10 Dec 2021
Dear Johannes,
thank you as well, it works.
Thank you guys,
take care,
Giulia.

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by