Even Numbers in a matrix a

I have a matrix 1 through 20 and i need to make a new matrix b with even numbers 1 through 20

Answers (1)

madhan ravi
madhan ravi on 31 Oct 2018
Edited: madhan ravi on 31 Oct 2018
a=1:20
b=a(rem(a,2)==0)

5 Comments

The above example illustrates to pick up even numbers from the given matrix
so a=1:20 how do i define b to equal the even numbers of a
See edited answer
If you got the answer to your question make sure to accept the answer so people know question is solved else let know
This answer works

Sign in to comment.

Asked:

on 31 Oct 2018

Commented:

on 27 May 2021

Community Treasure Hunt

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

Start Hunting!