Effacer les filtres
Effacer les filtres

Create a character cell in ascending order

3 vues (au cours des 30 derniers jours)
ARN
ARN le 9 Jan 2019
Modifié(e) : Stephen23 le 9 Jan 2019
i want to create a cell of 1000*1 , containing the strings in ascending order.
Let's say variable1, variable2,....variable999,variable1000. How can i do that with for loop?

Réponse acceptée

madhan ravi
madhan ravi le 9 Jan 2019
Modifié(e) : madhan ravi le 9 Jan 2019
With loop:
for i =1:1000
{sprintf('variable%d',i)} % if you remove { } it's string array
end
Without loop:
compose('variable%d',(1:1000).') % cell array
compose("variable%d",(1:1000).') % string array

Plus de réponses (1)

Stephen23
Stephen23 le 9 Jan 2019
Modifié(e) : Stephen23 le 9 Jan 2019
N = 1000;
C = cell(1,N);
for k = 1:N
C{k} = sprintf('variable%d',k);
end

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by