make cell and put number on it

n=20;
I want to make a cell from 1 to n
result should be
result={[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20]}

 Respuesta aceptada

Rik
Rik el 11 de Mzo. de 2019
You can do it like this:
n=20;
result=num2cell(1:n);

3 comentarios

NA
NA el 12 de Mzo. de 2019
if I want this result. What should I do?
T={'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20'}
Rik
Rik el 12 de Mzo. de 2019
T=cellfun(@num2str,result);
NA
NA el 12 de Mzo. de 2019
Thanks.
T=cellfun(@num2str,result,'UniformOutput', false);
without 'UniformOutput', false I have an error

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

NA
el 11 de Mzo. de 2019

Comentada:

NA
el 12 de Mzo. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by