Get the mean of the matrix and extract the elemnts fromthe matrix that are greater than the mean

1 回表示 (過去 30 日間)
Hello,
I have a matrix C=[50; 20; 50; 70; 30]; Now i want to find the mean of the array. mean_val=mean(C); I get the meanvalue as (mean_val=46) Now i want check if any of the elements in matrix C are greater than 46. If they are greater than 46 then extract those values from the matrix and get a new matrix excluding the elements which are greater than the mean value.
output Array after extracting the elements grater than mean val
output=[20; 30]; please let me know the function matlab to get this. Looking forward to hear from you
Thanks Pankaja

採用された回答

Mischa Kim
Mischa Kim 2015 年 2 月 20 日
How about
ouput = C(C<mean(C))
  2 件のコメント
Pankaja Tanjore
Pankaja Tanjore 2015 年 2 月 20 日
Hello,
Thanks for the reply Pankaja
Elias Gule
Elias Gule 2015 年 2 月 20 日
Mischa's answer is correct: try the following:
tic; output = C(C<sum(C)/length(C)); t0 = toc; tic; output = C(C<mean(C)); t1 = toc;
you should see that t1>t0. WHY? FYI: type edit mean.m in the command window to see the implementation of the mean function.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by