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 个评论
James Tursa
2020-4-30
What have you done so far? What specific problems are you having with your code?
回答(1 个)
James Tursa
2020-4-30
编辑:James Tursa
2020-4-30
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!