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!