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!