using textscan
조회 수: 2 (최근 30일)
이전 댓글 표시
Is textscan the correct command to use when importing data from text files into matlab. The command seems to work fine if I only have a vector in the text file, but if I have a matrix, matlab will change the structure of the data and store the matrix as a vector. Which command should I use if I'm importing data from text files within a loop where some of the text files include vectors and others include matrices?
댓글 수: 0
채택된 답변
Oleg Komarov
2012년 2월 23일
You have to specify the right 'format', read example 8 to get an idea: http://www.mathworks.co.uk/help/techdoc/ref/textscan.html
댓글 수: 3
Oleg Komarov
2012년 2월 23일
Headers do not matter, if you want 4 columns the right format is:
textscan(fid,'%f %f %f %f','Delimiter',''whateveryoulike')
or
textscan(fid,'%f',4,'Delimiter',''whateveryoulike')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!