# How would I write a script to solve this problem. Assume that I have a vector named D. Using iteration (for) and conditionals (if and/or switch), separate vector D into four vectors posEven, negEven, posOdd, and negOdd.

14 views (last 30 days)
Bryce Imbriale on 27 Sep 2018
Edited: OCDER on 28 Sep 2018
*Find the maximum, minimum elements and get the summation and so on, but how would I solve the problem using conditional statement and iterations instead.***
a. posEven contains all of the positive even numbers in D b. negEven contains all of the negative even numbers in D c. posOdd contains all of the positive odd numbers in D d. negOdd contains all of the negative odd numbers in D
Walter Roberson on 28 Sep 2018
What difficulty are you observing?

OCDER on 28 Sep 2018
Edited: OCDER on 28 Sep 2018
My guess is Bryce needs to "find the maximum and minimum elements, and get the summation" for each variable. But seems max, min, or sum cannot be used.
maxPosEven = posEven(1);
for j = 2:numel(posEven)
maxPosEven = posEven(j);
end
end