How can I convert all string cells in a table to numerical values?
Mostra commenti meno recenti
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 Commento
Note that you could easily use READMATRIX for that data file:
format long G
M = readmatrix('test.txt', 'NumHeaderLines',6)
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!