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]. 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].](/WebImages/13/use-matlab-script-enter-a-vector-named-vector-which-has-even-1016849-1761525492-0.webp)