Table define colums in more columns
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Frederik Reese
le 6 Mai 2022
Réponse apportée : Frederik Reese
le 6 Mai 2022
Hello I have the following problem: When I load data from a .dat file into matlab and create a table from it, matlab doesn't recognize the columns, so all the values are in one column.
Arc 2, Z, Time: 0 00:00:000,260450,285
I would like the table separated as below
Time Distance WSPL
Arc 2, Z, Time: 0 00:00:00 0,260 450,285
Thank you very much for your help.
3 commentaires
Réponse acceptée
Riccardo Scorretti
le 6 Mai 2022
Modifié(e) : Riccardo Scorretti
le 6 Mai 2022
Perhaps you need something like this?
load Test_Table.mat
tab = table('Size', [numel(Test_Table) 3], ...
'VariableNames', {'Time', 'Distance', 'WSPL'}, ...
'VariableTypes', {'string', 'double', 'double'});
tm = {} ; dst = [] ; swpl = [];
for n = 1 : size(Test_Table,1)
buffer = char(Test_Table{n,1});
tab.Time(n) = string(buffer(1:27));
tm{n,1} = buffer(1:27);
t = str2num(strrep(buffer(28:end), ',', '.'));
tab.Distance(n) = t(1);
tab.WSPL(n) = t(2);
end
tab
However, in my opinion, the point is rather how the original .dat file is imported.
4 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!