Edit:Value Exceeeds while dividing

I have 16 bit values and 14 bit values of same size
A=16 bit values ,B=14 bit values
i have sorted suxh a way that maximum value of 14 bit comes under max valu of 16 bit and so on,finally minimum of 14 bit comes min of 16 bit
used command as
[~,idx]=sort(A)
[~,idx1]=sort(idx)
C=B(idx1);
Dw=C./Cw
Dw=Dw*100;
the value of Dw exceeds 5 bit ,plese tell why i get this
suppose if max of 14 bit 8192/max of 16 bit 32767 we get 25 ,which is a 5 bit ,then why get more than 5 bit,please help

댓글 수: 8

Walter Roberson
Walter Roberson 2012년 11월 29일
What do you see as the point of doing the sort(idx) ? Are you trying to find indices of unique values? If the values are already unique then idx1 is just going to be (1 : length(A))
Pat
Pat 2012년 11월 29일
편집: Walter Roberson 2012년 11월 29일
A=[120 150 12 10 36 25 ];
B=[2 9 1 6 8 10];
i need as out=[9 10 2 1 8 6]
i tried using
[ii jj k]=unique(Sw);
B=unique(Cw);
P=B(k)
it works ,but suppose if my 14 and 16 bit consists of unique and negative values, what command must be used
Walter Roberson
Walter Roberson 2012년 11월 29일
I do not understand how you get out=[9 10 2 1 8 6] instead of out=[8 10 9 2 6 1] ?
Pat
Pat 2012년 11월 29일
편집: Pat 2012년 11월 29일
walter max of B is 10 ,so it comes undre max(A) which is 150,2nd position in out,min(B) is 1 is in 4th position in out because min(A) is in 4th position
Walter Roberson
Walter Roberson 2012년 11월 29일
Ah, okay I see that ordering now.
What problem do you see if your "14 and 16 bit consists of unique and negative values" ?
Pat
Pat 2012년 11월 29일
if i perform max(14bit)/max(16bit) i should get .25,but i get more value 12.12,dont have an idea of sorting negative and unique values
Walter Roberson
Walter Roberson 2012년 11월 29일
sort() and unique() work on negative values as well. Is the concern about the possibility that the max(16bit) might be negative and of small absolute value, but max(14bit) might be positive, leading to a large number divided by a number that is small absolute value?
Can you reproduce the large-result problem with a small demonstration vector that you could post?
A1 =
-443 -221 -266 89 -45 -266 -177 -133 -266 -266 -177 140
B1 =
-66 -55 33 78 122 111 66 22 22 -33 -78 -78

댓글을 달려면 로그인하십시오.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 11월 29일

0 개 추천

[~,i1] = sort(A);
B1 = sort(B);
[~,i2] = sort(i1);
C = B1(i2);

댓글 수: 1

Pat
Pat 2012년 11월 29일
Andre i have negative and unique values in it..my max(B) is 1540 and max(32768)
so 1540/32768 is 0.0470
but i get maximum 0.0995 after dividing C./A

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 11월 29일

0 개 추천

Remember, negative divided by negative gives positive, so if -12 as a 14 bit number happened to get paired with -1 as a 16 bit number, the ratio would be -12/-1 which would be 12.
But you don't even need to take into account negatives for this. If 12 as a 14 bit number happened to get paired with 1 as a 16 bit number, the ratio would be 12 anyhow. Consider for example
14 bit: [12 30]
16 bit: [1 100]
then 12/1 = 12, 30/100 = 1/3, so the ratio of their maximums (30, 100) would be much smaller the internal ratio.

카테고리

도움말 센터File Exchange에서 Pie Charts에 대해 자세히 알아보기

태그

질문:

Pat
2012년 11월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by