Program that separates even and odd numbers and shows them in two vectors.
조회 수: 2 (최근 30일)
이전 댓글 표시
The program must throw 100 in two vectors, in one the 50 pairs will be shown and in the other 50 odd. All this using the cilco for and conditions if they are necessary. I already got him to throw the numbers but to separate them.
댓글 수: 0
채택된 답변
추가 답변 (1개)
KSSV
2019년 2월 4일
A = magic(5) ;
A = A(:) ;
idx = mod(A,2)==0 ;
E = A(idx) ; % Even numbers
O = A(~idx) ; % Odd numbers
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!