Automaticlly converting negative values to 0
3 views (last 30 days)
Show older comments
Abad Ch
on 18 May 2020
Answered: Sulaymon Eshkabilov
on 18 May 2020
Hey. This is my code.
Ex_UpperBar * Ey_UpperBar * image(x_LowerBar,y_LowerBar)
Ex_UpperBar * Ey_UpperBar
ans =
-1
image(x_LowerBar,y_LowerBar)
ans =
uint8
89
but it is giving the Answer:
Ex_UpperBar*Ey_UpperBar*image(x_LowerBar,y_LowerBar)
ans =
uint8
0
It is supposed to return -89. How do i fix it? Thanks
0 Comments
Accepted Answer
Sulaymon Eshkabilov
on 18 May 2020
Use a command int8() or int16() to store your processed data that resolves your task. e.g.: a= -89; b=int8(a)
0 Comments
More Answers (2)
Sulaymon Eshkabilov
on 18 May 2020
Edited: Sulaymon Eshkabilov
on 18 May 2020
uint8 cannot store -89 and thus, 0
Thus, store your data in int8 or better int16.
0 Comments
Sulaymon Eshkabilov
on 18 May 2020
Store you data in int8 or int16
2 Comments
Walter Roberson
on 18 May 2020
int16(Ex_UpperBar)*int16(Ey_UpperBar)*int16(image(x_LowerBar,y_LowerBar))
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!