concatenating array using cellstr and repmat

1 visualización (últimos 30 días)
Leor Greenberger
Leor Greenberger el 2 de Mayo de 2013
Hi All,
I have the following code
str = cellstr(char('This','Orthis'));
x = round(rand(10,1))+1;
output = [repmat('some text ',10,1) str{x}]
I want the output to look like:
output =
some text OrThis
some text This
some text This
etc..
where the last word in each row is selected by str{x}. This is not working, as the str{x} part of the concatenation is not generating the appropriate array. Any suggestions? Thanks!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 2 de Mayo de 2013
str = cellstr(char('This','Orthis'))
x = round(rand(10,1))+1
output = [repmat('some text ',10,1) char(str(x))]

Más respuestas (0)

Categorías

Más información sobre Cell Arrays 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