How can I convert cell contents to a matrix?

2 vues (au cours des 30 derniers jours)
Jacob Lobao
Jacob Lobao le 21 Mar 2019
Commenté : Jacob Lobao le 21 Mar 2019
I am trying to import text files, and convert it's data into a matrix. When I import the file, it stores it as a 50x1 cell, how can I convert this to a 50x9 or 50x10 matrix, where I can reference each aspect of the file individually?
fid = fopen ('40_8deg_HL_Both.txt', 'r');
data = textscan(fid, '%s', 'HeaderLines', 9, 'delimiter', '/n');
fclose (fid);
mat = data{:};
  3 commentaires
Stephen23
Stephen23 le 21 Mar 2019
@Jacob Lobao: please upload a sample file by clicking the paperclip button.
Jacob Lobao
Jacob Lobao le 21 Mar 2019
This is the file used in the script^

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 21 Mar 2019
Modifié(e) : Andrei Bobrov le 21 Mar 2019
T = readtable('40_8deg_HL_Both.txt','ReadVariableNames',false,...
'Format','%{yyyyMMdd hh:mm:ss.SSS}D %f %f %f %f %f %f %f %q',...
'HeaderLines',9);
and please attach your txt-file.

Plus de réponses (1)

KSSV
KSSV le 21 Mar 2019
Read about readtable. This is the best function to use for your case.

Catégories

En savoir plus sur Data Type Conversion 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!

Translated by