How to make string from matrix?

1 visualización (últimos 30 días)
Lolipop
Lolipop el 19 de Dic. de 2014
Comentada: Lolipop el 19 de Dic. de 2014
Hello everyone.. Can anoyne help me with this.. I have matrix with dimension 662x2 for example
y=[111 20;123 43;117 89;....] on so on
and form that matrix I need to make string but in every new row to put '#' so matrix y should be converted in string like this
yy='111 20#123 43#117 89#..' and so on
Thank you!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 19 de Dic. de 2014
A=magic(4)
B=[num2cell(A');repmat({'#'},1,size(A,1))]
out=strjoin(cellfun(@num2str,B(:)','un',0))

Más respuestas (1)

Star Strider
Star Strider el 19 de Dic. de 2014
This works:
yy = sprintf('%d %d#', y');
  1 comentario
Lolipop
Lolipop el 19 de Dic. de 2014
Thank you this works as well

Iniciar sesión para comentar.

Categorías

Más información sobre Resizing and Reshaping Matrices 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