How to enter characters in cell array ?

5 visualizaciones (últimos 30 días)
TEEH
TEEH el 29 de Mayo de 2016
Comentada: TEEH el 29 de Mayo de 2016
I would like to create a cell array with the following output
A = a_1 a_2 a_3 a_4 ....... a_99
I am trying to use the loop method but it's not working. Can anyone help?
A=[];
for i= 1:99
A = [A, 'a_i']
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Mayo de 2016
A={}; for i= 1:99 A = [A, sprintf('a_%d', i)]; end
  1 comentario
TEEH
TEEH el 29 de Mayo de 2016
I have made a 3 D matrix. But i need to give each element of this matrix a name so that it can be inserted in the cell array as I need to SET UP a Linear Program .

Iniciar sesión para comentar.

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 29 de Mayo de 2016
A=sprintf('a_%d',1:99)

Categorías

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