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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Data Types 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by