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

1 visualizzazione (ultimi 30 giorni)
The code should contain only one line.

Risposta accettata

Abhishek Jain
Abhishek Jain il 4 Ott 2016
You can use this code:
y = sum(x(rem(x,2)==1));

Più risposte (0)

Categorie

Scopri di più su Data Types in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by