How to do some calculations on nonzero nonNAN elements of an array
1 次查看(过去 30 天)
显示 更早的评论
I have an array of about 400*20 size and some of its members are NAN or zero. There is a second array of the same size which I need to divide the first array by corrsponding member of the second array: FirstArrayName./SecondArrayName
how can I exclude non zero non NAN elements from this calculation?
3 个评论
KALYAN ACHARJYA
2019-12-2
编辑:KALYAN ACHARJYA
2019-12-2
how can I exclude non zero non NAN elements from this calculation?
Are you want exclude zero or NaN or both?
There is no impact, if you divide directly without excluding the NaN and zero elements. NaN position reflects the NaN again and zero reflects the same zero, in addition you can suppress those elements in the result array also.
回答(1 个)
Tiago Dias
2019-12-2
Hello, is this what u want to do?
A = [1 NaN 2 NaN;3 1 4 5]
result = A(1,:) ./ A(2,:)
result =
0.3333 NaN 0.5000 NaN
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Mobile Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!