Q:

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

0

 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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

 nums = randi([50, 100], 1, 20);
 evens = nums(rem(nums,2)==0);
 odds = nums(rem(nums,2)~=0);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now