How to read text files in MATLAB
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I would like to ask you for help. I have to solve this problem. I have data (textfile) which are outlined bellow and I need to devide data into two cell array. Bold formated data into one cell array and other data into second one. Is it possible to use command textread or any similar command ?? Thank you for all the advice.
- NM F2 2 620364 1.620040 36.366491 0 1 0
- GC lead containing glass type
- ED 8.200000000E+000 9.200000000E+000 3.599000000E+000 2.000000000E-004 0 0
- CD 1.345333590E+000 9.977438710E-003 2.090731760E-001 4.704507670E-002 9.373571620E-001
- TD 1.510000000E-006 1.560000000E-008 -2.780000000E-011 9.340000000E-007 1.040000000E-009
- OD 1.60000 1.00000 0.00000 1.00000 2.30000 1.30000
- LD 3.20000000E-001 2.50000000E+000
- IT 3.20000E-001 0.00000E+000 2.50000E+001
- IT 3.34000E-001 2.11000E-001 2.50000E+001
- IT 3.50000E-001 7.80000E-001 2.50000E+001
- IT 3.65000E-001 9.21000E-001 2.50000E+001
- IT 3.70000E-001 9.40000E-001 2.50000E+001
- IT 3.80000E-001 9.63000E-001 2.50000E+001
- IT 3.90000E-001 9.77000E-001 2.50000E+001
- IT 4.00000E-001 9.85000E-001 2.50000E+001
- IT 4.05000E-001 9.87000E-001 2.50000E+001
- IT 4.20000E-001 9.91000E-001 2.50000E+001
- IT 4.36000E-001 9.93000E-001 2.50000E+001
- IT 4.60000E-001 9.94000E-001 2.50000E+001
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 11월 4일
편집: Azzi Abdelmalek
2013년 11월 4일
fid = fopen('file.txt');
res={};
while ~feof(fid)
res{end+1} =fgetl(fid);
end
fclose(fid);
out1=cellfun(@(x) x(1:2),res,'un',0)'
out2=cellfun(@(x) x(4:end),res,'un',0)'
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!