How can I convert all string cells in a table to numerical values?
Show older comments
Hi I'm trying to import a text file into a table format. The text file is separated by single spaces, which I have included as an attachment. However, several columns have the data wrapped in a quote mark - why is this and what can I do to remove them? My matlab code looks as follows:
filename = 'test.txt';
T = readtable(filename,'Delimiter',' ','ReadVariableNames',false);
T([1],:) = [];
size(T);
EDIT: I see now the quote marks represent a string in the cell, but how can I convert all the strings to numerical values?
1 Comment
Note that you could easily use READMATRIX for that data file:
format long G
M = readmatrix('test.txt', 'NumHeaderLines',6)
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings 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!