How can i define a variable in a permanent data type ?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!