Question: Spring 2020 -- Math 131 Numerical Methods for Engineers and Scientists - Section 20 > Feb_11_worksheet > Determine even and odd integers from an array

Spring 2020 -- Math 131 Numerical Methods for

Spring 2020 -- Math 131 Numerical Methods for Engineers and Scientists - Section 20 > Feb_11_worksheet > Determine even and odd integers from an array O solutions submitted (max: Unlimited) For the following set of exercises we will be determining odd and even integers from an array. DO NOT USE SEMICOLON to suppress your outputs. 1. Create a vector called V, which consists of all integers from -3 to 5. 2. Use the MATLAB function mod on the vector V to determine which integer is even. Call the result new. For example, mod(-2,2) = 0 where 0 is the remainder of dividing -2 by 2. Hence, -2 is an even number. 3. Pick up the even integers by doing the following: E = V(new == 0). new == 0 will give you True/False results in 1's and 0's. O means that particular integer is even. Hence, V(new == 0) will give you all the even numbers from the array. 4. Create a vector called B, which consists of all integers from -3 to 5. 5. Use the MATLAB function mod on the vector b to determine which integer is odd. Call the result b. For example, mod(-3,2) = 1 where 1 is the remainder of diving -3 by 2. Hence, -3 is an odd number. 6. Pick up the odd integers by doing the following: 0 = B(b == 1). new == 1 will give you True/False results in 1's and O's. 1 means that particular integer is odd. Hence, O = B(b == 1) will give you all the odd numbers from the array. Script C Reset MATLAB Documentation Run Script Assessment: Submit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!