Is there any valid commands in matlab like double2str and bin2str for data type conversion and storage?

Respuestas (2)

Awais Saeed
Awais Saeed el 14 de Nov. de 2021

0 votos

Doing
help bin2str
% and
help double2str
did not show any results from which I assume there are no such functions. Use num2str() or sprintf instead
binary = randi([0 1],1,10);
binaryStr = sprintf('%d', binary)
binaryStr2 = num2str(binary)
class(binaryStr)
class(binaryStr2)

1 comentario

if you strickly want a string then
binary = randi([0 1],1,10);
Str = sprintf("The binary string is: %s", num2str(binary))
Str = "The binary string is: 1 1 1 1 0 1 1 0 0 0"
class(Str)
ans = 'string'

Iniciar sesión para comentar.

Steven Lord
Steven Lord el 14 de Nov. de 2021

0 votos

See the functions listed on this category page in the documentation.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Nov. de 2021

Respondida:

el 14 de Nov. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by