How to mean all array?
2 次查看(过去 30 天)
显示 更早的评论
Hi, im using matlab r2018a
lets say i have array
A = [NaN 1 1; 2 NaN 2; 1 NaN 2; 4 2 2]
how to get mean of all of it?
i need the result is 1.888889
i try using
z = mean(A(:))
but the answer is
z = NaN
0 个评论
采纳的回答
更多回答(1 个)
Walter Roberson
2021-6-16
format long g
A = [NaN 1 1; 2 NaN 2; 1 NaN 2; 4 2 2]
mean(A, 'all', 'omitnan')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!