How to create an array with the same letter but different number
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tiago Dias
el 17 de Oct. de 2018
Comentada: Jan
el 17 de Oct. de 2018
Hi,
How can I create an array or cell, something like Variable = {'X1','X2','X3',...,'X43'}? when i give for example the length = 43.
So when I do my plots, i call put the title as title (variable(i))
Thanks!
1 comentario
Adam
el 17 de Oct. de 2018
Variable = arrayfun( @(x) ['X', num2str( x )], 1:43, 'UniformOutput', false )
would create them all upfront.
Respuesta aceptada
Jan
el 17 de Oct. de 2018
Len = 43;
V = sprintfc('X%d', 1:Len);
Or with modern Matlab versions:
V = compose('X%d', 1:Len);
Then:
title(V{i})
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing 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!