The summation of elements between two numbers

2 ビュー (過去 30 日間)
Ellen
Ellen 2022 年 11 月 20 日
回答済み: David Hill 2022 年 11 月 20 日
We have made a matrix with 7 rows and 18 columns with random elements between 10-100. From these we have solved that there are 21 elements with a value between 35 and 55.
Now we have to calculate the summation of these 21 elements. How do we do that?

採用された回答

David Hill
David Hill 2022 年 11 月 20 日
yourMatrix=rand(7,18)*90+10;
s=sum(yourMatrix(yourMatrix>=35&yourMatrix<=55))
s = 1.3268e+03

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by