Importdata does not load last NaN of array

Hello to all. I am trying to read multiple files with importdata. The all have the same delimiter (,), but not the same format on their elements. The problem is that when a file’s last element is NaN, matlab does not load it, and as a result it loads the data with one less element. That is a problem because the matrix dimensions of all files should be the same, for my script to continue. Is there any way to “force” importdata to read until the last element?
I give you an example of two different files that I have to read
File #1 (everything ok here!)
0.26722,0.89362,0.0090539,0.98804,2.512,0.082354,0.10638
File #2 (importdata reads just 0,NaN,0,0.99598,0,0)
0,NaN,0,0.99598,0,0,NaN
Thanx in advance
Sakis Karagiannidis

4 件のコメント

Jan
Jan 2018 年 5 月 17 日
What about using textscan with a specific format instead of the general purpose importdata?
Athanasios Karagiannidis
Athanasios Karagiannidis 2018 年 5 月 17 日
The files have different formats on the elements. For example element(1,1) for one file is 0.26722 while for another file is 0. I am trying with load and it seems to be working correctly.
KSSV
KSSV 2018 年 5 月 17 日
the matrix dimensions of all files should be the same you can add NaN at the end..if the dimension is less. Alrenatively you can explore textscan
Jan
Jan 2018 年 5 月 18 日
@Athanasios Karagiannidis: "0.26722" or "0" are both numbers, so this is not an example of different formats. '%f' works in both cases.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLarge Files and Big Data についてさらに検索

タグ

質問済み:

2018 年 5 月 17 日

コメント済み:

Jan
2018 年 5 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by