필터 지우기
필터 지우기

Create a character cell in ascending order

조회 수: 3 (최근 30일)
ARN
ARN 2019년 1월 9일
편집: Stephen23 2019년 1월 9일
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?

채택된 답변

madhan ravi
madhan ravi 2019년 1월 9일
편집: madhan ravi 2019년 1월 9일
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

추가 답변 (1개)

Stephen23
Stephen23 2019년 1월 9일
편집: Stephen23 2019년 1월 9일
N = 1000;
C = cell(1,N);
for k = 1:N
C{k} = sprintf('variable%d',k);
end

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by