Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to fix this code and make it run? Thank you. X Determine even and odd integers from an array 2 solutions submitted (max: Unlimited)

image text in transcribedHow to fix this code and make it run? Thank you.

X Determine even and odd integers from an array 2 solutions submitted (max: Unlimited) View my solutions 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 O'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: O = B(b == 1). new== 1 will give you True/False results in 1's and 0'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 1 V = (-3,-2,-1,0,1,2,3,4,5 ] mod(-2,4)==0 E= V(new==0) 4 allTheEven Integers-V(E) 5 B= [ -3,-2,-1,0,1,2,3,4,5 ] mod(-3,2)==1 O=B (b==1) 8 allTheoddIntegers=B (0) Run Script Output - -3 -2 -1 0 1 2 3 4 5 ans = logical Unrecognized function or variable 'new'. Error in solution (line 3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions