How can i define a variable in a permanent data type ?
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Image Analyst
on 6 Dec 2013
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.
0 Comments
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!