필터 지우기
필터 지우기

Import an oddly shaped txt file

조회 수: 1 (최근 30일)
ayat
ayat 2016년 3월 29일
답변: KSSV 2016년 3월 29일
I have a txt file that is with a weird shape as you can see in the attached. When I use the import feature in matlab and choose nemeric matrix, the imported matrix looks like it should (each value allocated to the correct number on the second row). I don`t know how to replicate that in code. On a side note, is it possible to replace the "," with "." and then import?

답변 (1개)

KSSV
KSSV 2016년 3월 29일
clc; clear all ;
file = 'B00001.txt' ;
fid = fopen(file,'r') ;
S=textscan(fid,'%s','delimiter','\n');
fclose(fid) ;
S = S{1} ;
All the file contents will be saved in cell S. You can do what ever you want from S.
Note that there are many other ways to read a file.

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by