Place string in front of vector
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a vector of numbers: num = [1:16]; I would like to place the character: 'B' in front of each number i that vector without using the for loop.
Are there any tricks to do this quickly?
The result should look like this:
[B1 B2 B3 B4........]
thanks.
1 comentario
Respuesta aceptada
Matt J
el 26 de Oct. de 2012
result = arrayfun(@(i) ['B',num2str(i)] , num , 'uni',0);
0 comentarios
Más respuestas (1)
Azzi Abdelmalek
el 26 de Oct. de 2012
Editada: Azzi Abdelmalek
el 26 de Oct. de 2012
[ '[' sprintf('B%d ',1:16) ']']
Ver también
Categorías
Más información sobre Numeric Types en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!