Write a single line code to sum all the odd numbers of an array.

1 回表示 (過去 30 日間)
Abhi Jain
Abhi Jain 2016 年 10 月 4 日
コメント済み: Abhi Jain 2016 年 10 月 4 日
The code should contain only one line.

採用された回答

Abhishek Jain
Abhishek Jain 2016 年 10 月 4 日
You can use this code:
y = sum(x(rem(x,2)==1));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by