How to read data from a file

I have difficulty reading data from a file into an array
(or arrays). The file looks like the following (3 rows, 6
columns):
1,0,0.99539,-0.05889,0.85243,g
1,0,1,-0.18829,0.93035,d
1,0,1,-0.03365,1,g
Thanks, Min

 채택된 답변

Andrew Newell
Andrew Newell 2011년 3월 18일

0 개 추천

This will read it into a cell array (assuming your file name is mixedData.m):
fid = fopen('mixedData.m');
C = textscan(fid,'%f %f %f %f %f %s','Delimiter',',')
fclose(fid)
C{1}
ans =
'g'
'd'
'g '

댓글 수: 1

MIN
MIN 2011년 3월 19일
Thank you very much. This is very helpful.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Text Analytics Toolbox에 대해 자세히 알아보기

제품

질문:

MIN
2011년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by