How can i solve this?
1 回表示 (過去 30 日間)
古いコメントを表示
For a given rectangular matrix A, it is required to find the number of elements that exceed in absolute value the arithmetic mean of all elements of this matrix.
A=rand(3,4)
M=mean(mean(A))
A(:)
x=abs(M)
c=0
fori = length(ans)
if (ans(i)>abs(x))
c=c+1
end;
i did this. Is this even the solution of that question?im new to matlab
0 件のコメント
採用された回答
David Hill
2020 年 5 月 27 日
a=mean(abs(A),'all');
s=sum(A>a,'all');
2 件のコメント
David Hill
2020 年 5 月 27 日
Sorry, I misunderstood you. You want to take the mean first, then abs. Here is a one-liner that will work for you.
s=nnz(A>abs(mean(A,'all')));
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!