MATLAB Quastion Generate a vector of 20 random integers each
MATLAB Quastion
Generate a vector of 20 random integers. each in the range from 50 to 100. Create a variable evens that stores all of the even numbers from the vector, and a variable odds that stores the odd numbers.Solution
20 random values;
 variables=randi([50 100],20,1)
 evenvector=variables(mod(variables,2)==0);
 oddvector=variables(mod(variables,2)~=0);
 ouptput:
 52
 72
 28
 62
 54
 56
 58
 96
 68
 77
 65
 51
 odd vector:
 51
 59
 57
 61
 97
 99
 75
 

