Matlab Help!! vector/if statement and for loop

Thread Starter

Judas543

Joined Jan 26, 2010
60
Don't really know where to begin but here's what information they give and what i have so far. I guess what my question is, is what am i suppose to do and how am i suppose to do it. It says i need to use iteration, so that means "for x=" then if->else if>else if->else-> end" format right? SO could someone help me start it

Separating a vector into 6 subsets:



%Use the following vector given for Matlab:
D = [ 23, -5, 4, 0, -10, 45, 3, -3, 34, -9, 1, 25, 87, 21, -7, 4, -2, 6, 62, -22, -6, -17]

posEven = [4,34,4,6,62]

negEven = [-10,-2,-22,-6]

posodd = [23,45,25,87,21]

negodd = [-5,-3,-9,-7,-17]

posNeg = [1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0]

big = [45, 34, 87, 62]





Example given to us:

If D = [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 34, 87],
posEven=[2,4,34]
negEven=[-4,-2]
posOdd=[l,3,5,87]
negodd=[-3,-1]
posNeg = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1] and
big = [34, 87]

Use the following vector (copy and paste in Matlab):

D = [ 23, -5, 4, 0, -10, 45, 3, -3, 34, -9, 1, 25, 87, 21, -7, 4, -2, 6, 62, -22, -6, -17]
 
Top