Data type conversion for mod operation result.

Hi, I am working with Matlab 2010b. I need to change the default datatype[double] in mod operation to uint8/unit16...?? Could you please guide me...

답변 (2개)

Purushottama Rao
Purushottama Rao 2015년 6월 25일

0 개 추천

c=int16(mod(200,3))
will generate c as 16 bit integer class
c=int8(mod(200,3))
will generate c as 8 bit integer class

댓글 수: 1

Dharani T
Dharani T 2015년 6월 27일
Thanks for the info... I will try with the option you have mentioned..

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2015년 6월 25일

0 개 추천

If one input has an integer data type, then the other input must be of the same integer data type or be a scalar double.
When you do use an integer datatype for either parameter, the output will be in that datatype.
If you want mod() to return a different datatype than double then you need to input your parameters as that datatype. Otherwise you need to convert afterwards as shown by Purushottama Rao

태그

질문:

2015년 6월 25일

댓글:

2015년 6월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by