How to read this file in MATLAB?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am having trouble reading the datas.
댓글 수: 0
답변 (2개)
Turlough Hughes
2019년 11월 11일
You can use the following to read your into a variable D.
fid=fopen('silicon_simr1.txt');
fgetl(fid)
VarNames=fgetl(fid);
strsplit(VarNames)
c=1;
while true
data=fgetl(fid);
if data==-1
break
end
D(c,1:2)=str2num(data);
c=c+1;
end
댓글 수: 0
James Kennedy
2019년 11월 11일
This data file is tricky because of the unique combination of delimiters. It does use a simple tab or a fixed space.
I was able to import the data using the MATLAB import Data GUI:
I found that a combination of two custom delimiters acting as a single delimeter worked best (three spaces: 'SpaceSpaceSpace' and five spaces:'SpaceSpaceSpaceSpaceSpace'):
You can either import your data directly through the GUI or use it to create a script or function. I've attached a function which was created by MATLAB which should work for your data.
Here is a plot of the data for verification:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!