MATLAB Answers

0

Data type conversion in Matlab

Asked by Abdurrehman on 26 Aug 2017
Latest activity Answered by KSSV
on 26 Aug 2017
Accepted Answer by KSSV
I have a fundamental question i.e. if I write in Matlab
Variable = 10;
the variable will be of double class and 8 bytes wide.
now if I change its type as
variable=uint8(variable);
it will be converted to an unsigned int and will be 1 byte wide
The problem is here when I assign a new value to this variable it changes its class automatically and goes back to double class whereas I had changed its class from double to uint8.
Can anyone address this issue, please?

  0 Comments

Sign in to comment.

Products

1 Answer

KSSV
Answer by KSSV
on 26 Aug 2017
 Accepted Answer

Default class in matlab is double. If you want class uint8 every time you have to use it.

  0 Comments

Sign in to comment.