MATLAB: Bin edges of discretize function excluding some bins

.bincategoricalclassificationdiscretizehistogramMATLABstatistics

Hello.
mtransf is 100×5000 double where I have some values between -1.3 and 1.3 in each column. I add the mean in row 101 of mtransf:
mtransf(101,:) = mean(mtransf, 1);
I want to discretize the data and make categories in row 102 based on the mean values. With if loops in for loop it works fine but solution is not elegant:
% for i=1:5000
% if (-1.3<=mtransf(101,i)) && (mtransf(101,i)<=(-1.0))
% mtransf(102,i)=1;
% elseif (-1.0<mtransf(101,i)) && (mtransf(101,i)<=(-0.8))
% mtransf(102,i)=2;
% elseif (-0.8<mtransf(101,i)) && (mtransf(101,i)<=(-0.6))
% mtransf(102,i)=3;
% elseif (0.8>=mtransf(101,i)) && (mtransf(101,i)>=0.6)
% mtransf(102,i)=4;
% elseif (1.0>=mtransf(101,i)) && (mtransf(101,i)>0.8)
% mtransf(102,i)=5;
% elseif (1.3>=mtransf(101,i)) && (mtransf(101,i)>1.0)
% mtransf(102,i)=6;
% end
I want to do the same task with discretize, but without the bin between -0.6 and 0.6 :
binEgdes = [-1.3 -1.0 -0.8 -0.6 0.6 0.8 1.0 1.3];
catnames = ["1","2","3","4","5","6","7"];
mtransf(102,:)=discretize(mtransf(101,:),binEgdes,"Categorical",catnames);
Thank you.

Best Answer

mtransf(102,:) = discretize(mtransf(101,:),binEgdes,"Categorical",catnames);
mtransf(102,mtransf(102,:)==4)=NaN;