Hi, I have an array
S=[ -2.8933 -2.3867 -11.5800 -17.3733 0 22.8400 32.9800 23.0533 6.4933 0.0000 27.2333 44.0333 30.2333 7.1333 0 40.2267 84.8867 138.0800 131.7400 -0.0000]
I need to apply these lines of code on every 5 values
[Max,MaxIdx]=max(S) [Min,MinIdx]=min(S)for n=1:5 code(n)=0 if n>=MinIdx & n<=MaxIdx || n<=MinIdx & n>=MaxIdx if MaxIdx > MinIdx code(n)=1 else if MinIdx > MaxIdx code(n)=2 end endendend
the result array code, should be 0 0 0 1 1 0 2 2 2 2 0 2 2 2 2 0 0 2 2 2
Best Answer