필터 지우기
필터 지우기

How to put strings inside the cell of an array continously ?

조회 수: 1 (최근 30일)
Mohan
Mohan 2013년 2월 25일
is it possible to have a single line inside a for loop for generating the following code ?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
img_names{1} = ['1.png'];
img_names{2} = ['2.png'];
img_names{3} = ['3.png'];
img_names{4} = ['4.png'];
img_names{5} = ['5.png'];
img_names{6} = ['6.png'];
img_names{7} = ['7.png'];
img_names{8} = ['8.png'];
img_names{9} = ['9.png'];
img_names{10} = ['10.png'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

채택된 답변

Thorsten
Thorsten 2013년 2월 25일
for i = 1:10
image_names{i} = [int2str(i) '.png'];
end

추가 답변 (1개)

Jos (10584)
Jos (10584) 2013년 2월 25일
Or hide the for-loop all together:
x = 1:10
NM = cellstr(num2str(x(:),'%d.png'))

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by