Importing a numeric data text file with missing data
이전 댓글 표시
Hi
I am trying to load multiple files onto matlab . The files contain the results of nonlinear dynamic analysis on a structure. So they are in the form of a matrix with multiple rows and columns. Due to convergence problem or so, some of the analyses were terminated earlier that they complete and as a result some of the output files are not complete. It means there are some empty elements which is on the last row essentially.
I am trying load these files but unfortunately , matlab gets me an error due to those files with missing data. I am using the load command to import the files .
Is there any way that I can import those files , I am happy with zeroes to be placed where the data are missing too.
Thanks Reza.
댓글 수: 11
Star Strider
2015년 10월 3일
Attach one of the problem files to your original Question. (Use the ‘paperclip’ icon, and complete both the ‘Choose file’ and ‘Attach file’ steps.)
Reza
2015년 10월 3일
Star Strider
2015년 10월 3일
I have no idea how to read that. What application wrote it? Can you export it in another format?
The problem is that it’s a series of run-together numbers with no structure I can recognise. MATLAB does not have field-specific file reading (FORTRAN does), so it has to be in a format MATLAB can work with.
Please upload your data as an original text file, or in some other standard format, such as an Excel file.
Reza
2015년 10월 3일
Star Strider
2015년 10월 3일
That isn’t the format of the ‘Sample’ file. The one you posted in your comment would be relatively easy to read and work with.
Reza
2015년 10월 3일
per isakson
2015년 10월 4일
편집: per isakson
2015년 10월 4일
With data from Sample.zip. Does this solve it?
fid = fopen( 'C:\tmp\Long_col_drift_4000619.out' );
cac = textscan( fid, '%f%f', 'Collectoutput', true );
fclose( fid );
num = cac{:};
num( end-3:end, : )
it outputs
ans =
103.0350 -0.0004
103.0400 -0.0004
103.0450 -0.0004
103.0500 NaN
the missing data is indicated with NaN
per isakson
2015년 10월 4일
편집: per isakson
2015년 10월 4일
"120 column instead of just 2"   Replace %f%f by repmat('%f',[1,120])
"zero instead of NAN?"   num(isnan(num))=0;   or add   'EmptyValue',0   to textscan
Reza
2015년 10월 4일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!