Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

why i get an error ?

조회 수: 1 (최근 30일)
Sultan Mehmood
Sultan Mehmood 2019년 7월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
II=[114 223;176 155];
R=II(:)';
x=0.3;
p=0.343;
for n=2:4;
if x(n-1)>=0 & x(n-1)<=p
x(n)=x(n-1)/p;
else
x(n)=(1-x(n-1))/(1-p);
end
end
A=sort(x);
[A,T]=sort(x);
Y=R(T);
r = 3.342448;
L(1)= 0.234;
for i=2:4
L(i) = r*L(i-1)*(1-L(i-1));
end
mm=min(L);
nn=max(L);
oo=nn-mm;
Z=uint8(254*((L-mm)/oo))+1;
SS=mod((Y+Z),256)
problem in SS.

답변 (1개)

KSSV
KSSV 2019년 7월 15일
Z=uint8(254*((L-mm)/oo))+1;
Y = uint8(Y) ;
SS=mod((Y+Z),256)
Note that same class varibales only can be added. A integer shoud ld be added to integer. So ocnvert your variable Y, which is double to unit8.
  댓글 수: 3
KSSV
KSSV 2019년 7월 16일
In this case your Y and Z are double.......convert them to uint8.
Yash Totla
Yash Totla 2019년 7월 17일
Z has been typecasted to uint8. When you perform Y+Z it is also typecasted to uint8 datatype. Now if the value of the expression is capped at 255 because that is the max value that you can store in it. So when you take the modulo with 256, it returns 255.
You can try to typecast the expression Y+Z to a datatype whose max value is more than 255. Taking the modulo of a uint8 with 256 is basically returning the same number in uint8.
Check this link for more information on numeric datatypes in matlab.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by