Question: Matlab 1. (for loop) Write a script to solve this problem. First use input(...) to ask for a vector and name it D. then use
1. (for loop) Write a script to solve this problem. First use input(...) to ask for a vector and name it D. then use iteration (for loop) and conditional (if or suritch) to separate Dinto four vectors posEven, neg Even, posOdd, and negOdd. posEven contains all of the positive even numbers in D negEven contains all of the negative even numbers in D posOdd contains all of the positive odd numbers in D neyOdd contains all of the negative odd numbers in D Requirement: You program should work for any input D, not just for one D you choose For example, if we input D = -5:5, the outputs should be posEven = 124 nogEven = 12-41 posOdd = [1351 megOdd = 1-1-3-51 Step 1: use input(...) to ask for a vector and name it D Step 2: initiate four output variables with empty vectors Step 3: start for loop Step 4: use conditional if or sunitch to test whether a number is posi- tiveegative, ovd/even. Then add the number to the right output vicc tor
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
