How can I convert cell contents to a matrix?

조회 수: 1 (최근 30일)
Jacob Lobao
Jacob Lobao 2019년 3월 21일
댓글: Jacob Lobao 2019년 3월 21일
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
Stephen23
Stephen23 2019년 3월 21일
@Jacob Lobao: please upload a sample file by clicking the paperclip button.
Jacob Lobao
Jacob Lobao 2019년 3월 21일
This is the file used in the script^

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 3월 21일
편집: Andrei Bobrov 2019년 3월 21일
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.

추가 답변 (1개)

KSSV
KSSV 2019년 3월 21일
Read about readtable. This is the best function to use for your case.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by