Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started