use matlab script Enter a vector named vector which has even

use matlab script

Enter a vector, named vector, which has even and odd integers, using the input statement. For example, the vector [26 15 -3 4 78 6 5 1 9 18]. Create a new vector, named evens, containing only the even integers in vector. The scripts should work with vectors of any length. Hint: the mod() function is useful to determine even and odd numbers.

Solution

R = input(\'Input your vector:\')
Input your vector:[26 15 -3 4 78 6 5 1 9 18]
evens=R(mod(R,2)==0); odds=R(mod(R,2)~=0);
Disp(evens) ;
Disp(odds) ;

use matlab script Enter a vector, named vector, which has even and odd integers, using the input statement. For example, the vector [26 15 -3 4 78 6 5 1 9 18].

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site