Converting each matrix entry to specific string

hi,
I have matrix
A=[1 2 3;4 5 6; 7 8 9]
I wanted to convert each matrix entry to specific string for example
A=[X(1) X(2) X(3);X(4) X(5) X(6); X(7) X(8) X(9)]
Any Suggestion Please!!!

2 comentarios

Azzi Abdelmalek
Azzi Abdelmalek el 17 de Nov. de 2013
What is X ?
its a string that is need to be replaced

Iniciar sesión para comentar.

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 17 de Nov. de 2013
arrayfun(@(ii) X(ii),A,'un',0)

5 comentarios

X(i) is a String that I want to replace, how can I replace this string. its giving me error because X and ii is unknown
Muhammad Ali Qadar
Muhammad Ali Qadar el 17 de Nov. de 2013
Editada: Muhammad Ali Qadar el 17 de Nov. de 2013
if ii=1:9 and X(ii)=ii; then arrayfun(@(ii) X(ii),A,'un',0) give following results
[1] [2] [3]
[4] [5] [6]
[7] [8] [9]
However I want this
X(1) X(2) X(3)
X(4) X(5) X(6)
X(7) X(8) X(9)
@Azzi Abdelmalek, Waiting for your Trick
A=[1 2 3;4 5 6; 7 8 9];
arrayfun(@(ii) sprintf('X(%d)',ii),A,'un',0)
Azzi Abdelmalek
Azzi Abdelmalek el 17 de Nov. de 2013
Editada: Azzi Abdelmalek el 17 de Nov. de 2013
%or
sprintf([repmat('X(%d) ',1,size(A,2)) '\n'],A')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Etiquetas

Preguntada:

el 17 de Nov. de 2013

Editada:

el 17 de Nov. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by