How do I single out elements in a vector?

If I was asked to single out the even elements in a vector say randi(100,1,100) How would I do that?
If I were to just want to know how many elements in the vector are even how would i do that?

1 Kommentar

James Tursa
James Tursa am 30 Apr. 2020
What have you done so far? What specific problems are you having with your code?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

James Tursa
James Tursa am 30 Apr. 2020
Bearbeitet: James Tursa am 30 Apr. 2020

0 Stimmen

Hints: You might look at the mod( ) or rem( ) function to determine if values are even. To determine how many are even, you could also look into the nnz( ) or sum( ) function on the results of the mod( ) or rem( ) function.

Gefragt:

am 30 Apr. 2020

Bearbeitet:

am 30 Apr. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by