convert NAN to zero in complex structs.
8 ビュー (過去 30 日間)
古いコメントを表示
Hi folks,
I am asking about converting NAN to zero in the complex struct data. Since I am using an input JSON file and open in the Matlab, it is a little bit difficult to change the whole structure as I wish.
Currently my data is 1*1 struct with 611 fields, and each field has 2 different fields and one of them is another 3*1 struct.
so it is like, under data I have data.x1 contains 2 field and under seconds field I have data.x1.data
If I have NAN under data.x1.data how can I get this value up to data.x611.data and convert it to '0'.
I tried to use 'if loop' but it seems like super complicated and long...
I am looking for the other way or simple way.
and advice for me?
Best Regards, Ali
3 件のコメント
Guillaume
2018 年 10 月 25 日
The NaN in matlab will come from null in the json. It probably would be simpler to replace these null in the json by 0 rather than navigating a possibly complex structure. The only danger may be that null may appear in th json as a field name or in a string (where it shouldn't be touched). Is this a possibility in your case?
If it's not then it's trivial to convert the null to 0. Otherwise, I'll have to think a bit more about which approach is the easiest.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で JSON Format についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!