How to make any math operation when there are NaN in data serial?
7 次查看(过去 30 天)
显示 更早的评论
How to make any math operation when there are NaN in data serial?
I'd like to make an test using in my data serial NaN...
For exemplo: I have 2 matrix (a and b) and I'd like of sum them!!!
Ex:
a=[1,2,3,NaN,5]
b=[1,2,3,8,5]
c=(a+b)
How can I to do?
采纳的回答
Image Analyst
2014-7-13
编辑:Image Analyst
2014-7-13
Try these two different approaches:
a=[1,2,3,NaN,5]
b=[1,2,3,8,5]
cWithNans = a + b % c(4) will = nan
nonNanLocations = ~isnan(cWithNans) % Location of indexes that are good.
cwithoutNans = cWithNans(nonNanLocations)
% c(4) is skipped and new c(4) = old c(5)
5 个评论
Image Analyst
2014-7-13
isnan() is a function that is the same length as the array that you pass it. It will be true or 1 where there is a nan in the array, and false or 0 where there is a good number. You can pass that in to the array as an index to extract all the elements of the array that are, or are not, nans.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!