About null values

4 ビュー (過去 30 日間)
Mtlb Usr
Mtlb Usr 2011 年 3 月 7 日
コメント済み: chocho 2017 年 4 月 5 日
Hi,
I'm using importdata(file) function to extract the file information as a matrix. Until now there isn't any problem.
However, when I catch a file where there are a null values,the function only obtains the previous lines until the first line where there is a null values.
How can I configure this function for not omit the null values?
thanks
regards
  3 件のコメント
Andrew Newell
Andrew Newell 2011 年 3 月 7 日
Importdata isn't bothered by zeros. It ignores blank lines and variable spacing between numbers, and can even handle missing data elements in a row (by appending NaN's to the end of the row). So what do you mean by null values?
Mtlb Usr
Mtlb Usr 2011 年 3 月 7 日
Hi,
Sorry, I haven't realized me that the info that I was reading was a string, because the value of the cell is null. E.g: ...;null;...
Then, the real reason of the issue is that the importdata() doesn't read the info joining the numbers and strings.
Finally, I think that as a solution it would be change these "null" values per NaN. Perhaps, for this way the function would can read all information in one matrix. Would be it correct?
thanks
regards

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

採用された回答

Mtlb Usr
Mtlb Usr 2011 年 3 月 14 日
Hi,
Finally, I got resolve this issue. it was a stupid thing, because I had only to check if the value was Null or not. But Null with the first letter with capital letter..important.
However, thank you for u answer.
regards
  1 件のコメント
chocho
chocho 2017 年 4 月 5 日
@Mtlb Usr hi bro how do you solve your problem? because I have the same problem.
i used importdata to read the file but when it get null is showing NaN and stop reading the rest of the file

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

その他の回答 (1 件)

Matt Tearle
Matt Tearle 2011 年 3 月 7 日
It sounds like this is a delimited text file, in which case I'd recommend using textscan. It will use NaN in place of missing values. You can also specify the TreatAsNan option to tell it that certain patterns are missing values.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by