Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago