How can i define a variable in a permanent data type ?

Hi, i'm working with some 16 bits integers and I am looking for a way to define their datatype permanently, because for now I'm using the int16() converting function every time my variable needs to be reassigned.
Example : (Uc1 & Er are int16 typed)
Uc1 = int16(1000*Uc1 + 536*Er);
would become (if variables are permanently typed)
Uc1 = 1000*Uc1 + 536*Er;
Thanks

답변 (1개)

Image Analyst
Image Analyst 2013년 12월 6일
If Er and Uc1 (incoming) are int16, then Uc1 will still be int16 afterwards. Just try it
Er = int16(11);
Uc1 = int16(33);
Uc1 = 1000*Uc1 + 536*Er
whos Uc1
But be aware that you're multiplying by some pretty big numbers and it could be possible (for some values of Uc1 and Er) to exceed the 32767 limit for int16 and get clipped to that value. So you might want to make Uc1 double so you don't get clipping.

카테고리

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

질문:

2013년 12월 6일

답변:

2013년 12월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by