How to repeat a cell?

조회 수: 4 (최근 30일)
andrew
andrew 2014년 2월 28일
댓글: andrew 2014년 2월 28일
I have a cell array and I would like to search for a specific string in the cell array and repeat that cell.
for example my cell array is 111x1 and I want to find 'a' and duplicate it right below the existing one so that the new cell array is 112x1.

채택된 답변

Wayne King
Wayne King 2014년 2월 28일
편집: Wayne King 2014년 2월 28일
Does it just occur once?
x = {'b','c','d','e','f','a','y','z','h','i','j'};
x = x(:);
y = cell(length(x)+1,1);
idxarray = strcmp(x,'a');
idx = find(idxarray == 1);
y{idx+1} = 'a';
y(1:idx) = x(1:idx);
y(idx+2:end) = x(idx+1:end);
  댓글 수: 1
andrew
andrew 2014년 2월 28일
How would you duplicate cells 27-50?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by