Write a script that prompts the user to enter a vector named
     Write a script that prompts the user to enter a vector, named vector, which has even and odd integers. 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.![Write a script that prompts the user to enter a vector, named vector, which has even and odd integers. For example, the vector [26 15 -3 4 78 6 5 1 9 18]. Crea  Write a script that prompts the user to enter a vector, named vector, which has even and odd integers. For example, the vector [26 15 -3 4 78 6 5 1 9 18]. Crea](/WebImages/8/write-a-script-that-prompts-the-user-to-enter-a-vector-named-994692-1761511858-0.webp) 
  
  Solution
Use the following code for the MATLAB.
% Create sample data.
 x = [26 15 -3 4 78 6 5 1 9 18]
 % Find indices where x is even:
 evenIndices = rem(x, 2) == 0
 % Extract only the even numbers into a new vector.
 allTheEvenNumbers = x(evenIndices)
 x = [26 15 -3 4 78 6 5 1 9 18]
 % Find indices where x is odd:
 oddIndices = rem(x,2)~=0
 % Extract only the odd numbers into a new vector.
 allTheOddNumbers = x(oddIndices)
![Write a script that prompts the user to enter a vector, named vector, which has even and odd integers. For example, the vector [26 15 -3 4 78 6 5 1 9 18]. Crea  Write a script that prompts the user to enter a vector, named vector, which has even and odd integers. For example, the vector [26 15 -3 4 78 6 5 1 9 18]. Crea](/WebImages/8/write-a-script-that-prompts-the-user-to-enter-a-vector-named-994692-1761511858-0.webp)
