MATLAB: Array values not corresponding to condition

noncorrosponding conditions

Hello
I have an array that has been which has been rounded to numbers of 1-5. ( i'll post the code below ). I have numbers which aren't corresponding to my given condition and instead take another condition, i was wondering if anyone can spot what i've done wrong.
" Round data is a 20 by 20 array of numbers rounded to numbers 1,2,3,4,5)
rangeValue1 = 1;
rangeValue2 = 2;
rangeValue3 = 3;
rangeValue4 = 4;
rangeValue5 = 5;
roundData (roundData < 0.4 & roundData > 0 ) = rangeValue1;
roundData (roundData < 0.8 & roundData > 0.4 ) = rangeValue2;
roundData (roundData < 1.2 & roundData > 0.8 ) = rangeValue3;
roundData (roundData < 1.6 & roundData > 1.2 ) = rangeValue4;
roundData (roundData < 2.0 & roundData > 1.6 ) = rangeValue5;

Best Answer

Your problems only arise because you used only "<" operators, so the numbers that are exactly in the middle of your intervals do not change. You should include "<=" operators, so that you will not loose any value re-mapping:
roundData (roundData <= 0.4 & roundData > 0 ) = rangeValue1;
roundData (roundData <= 0.8 & roundData > 0.4 ) = rangeValue2;
roundData (roundData <= 1.2 & roundData > 0.8 ) = rangeValue3;
roundData (roundData <= 1.6 & roundData > 1.2 ) = rangeValue4;
roundData (roundData <= 2.0 & roundData > 1.6 ) = rangeValue5;
Sure this work.