Can you remove certain characters from first column and each row of a table?
8 views (last 30 days)
Show older comments
Mihai Ciortuz
on 24 Jun 2019
Edited: Mihai Ciortuz
on 25 Jun 2019
I have this table:
files aMean
_____________________________ __________________
'C:\Users\dexte\OneDrive\Desktop\1' 3.38904290625e-10
'C:\Users\dexte\OneDrive\Desktop\2' 3.727809984375e-12
'C:\Users\dexte\OneDrive\Desktop\3' 4.03381559375e-10
'C:\Users\dexte\OneDrive\Desktop\4' 3.550222328125e-10
'C:\Users\dexte\OneDrive\Desktop\5' 3.75777240625e-10
'C:\Users\dexte\OneDrive\Desktop\6' 4.319917984375e-12
'C:\Users\dexte\OneDrive\Desktop\7' 4.1586619375e-10
I would like to have 1, 2 ,3, 4 in the first column instead of getting the whole filepath. Any help?
0 Comments
Accepted Answer
Image Analyst
on 25 Jun 2019
In a loop, get the filename and extract the last character(s) that are the number or use fileparts. Untested code:
for k = 1 : size(t, 1)
thisFileName = t.files{k}
[folder, number, ext] = fileparts(thisFileName)
t.files{k} = number;
end
That's untested so it might need some tweaking. Attach your table in a .mat file if you need more help.
More Answers (0)
See Also
Categories
Find more on String Parsing 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!