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!