Data type conversion for mod operation result.

3 visualizaciones (últimos 30 días)
Dharani T
Dharani T el 25 de Jun. de 2015
Comentada: Dharani T el 27 de Jun. de 2015
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...

Respuestas (2)

Purushottama Rao
Purushottama Rao el 25 de Jun. de 2015
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 comentario
Dharani T
Dharani T el 27 de Jun. de 2015
Thanks for the info... I will try with the option you have mentioned..

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 25 de Jun. de 2015
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

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by