Dear all,
I have this vector
DIFF=[ 0 0.0500 -0.0200 0.0100 -0.0400 0 0 0 0.0500 0 0.0200 0 0.0100 0 -0.0100 0 -0.1500 0 -0.0100 0];
and I want to make the following tranformation:
The values of DIFF<-0.02 to be tranformed to 1
The values of DIFF>=-0.02 & DIFF<-0.01 to be tranformed to 2
The values of DIFF>=-0.01 & DIFF<=0 to be tranformed to 3
The values of DIFF>0 & DIFF<=0.01 to be tranformed to 4
The values of DIFF>0.01 & DIFF<=0.02 to be tranformed to 5
The values of DIFF>0.02 to be tranformed to 6
So I constructed the following code
c1= -0.02; c2= -0.01; c3= 0; c4= 0.01; c5= 0.02;kk=size(DIFF,1); vy=zeros(kk,1); f1=find( DIFF<c1);f2=find(DIFF>=c1 & DIFF<c2);f3=find(DIFF>=c2 & DIFF<=c3);f4=find(DIFF>c3 & DIFF<=c4);f5=find(DIFF>c4 & DIFF<=c5);f6=find(DIFF>c5); vy(f1)=1;vy(f2)=2;vy(f3)=3;vy(f4)=4;vy(f5)=5;vy(f6)=6;
And I finally obtain the following matrix
DATA_NEW=[vy DIFF] 3.0000 0 6.0000 0.0500 1.0000 -0.0200 4.0000 0.0100 1.0000 -0.0400 3.0000 0 3.0000 0 3.0000 0 6.0000 0.0500 3.0000 0 5.0000 0.0200 3.0000 0 4.0000 0.0100 3.0000 0 3.0000 -0.0100 3.0000 0 1.0000 -0.1500 3.0000 0 3.0000 -0.0100 3.0000 0
But as you can see from the third element of DATA_NEW, the value of 1 is assigned to -0.02. But according to my categorization, the value of 2 should have been assigned to -0.02.
Similarly, the value of 6 is assigned to 0.05, but it should be the value of 5.
How could I rectify this problem given the fact that my real DIFF vector contains thousands of elements.
Thanks in advance
Best Answer