필터 지우기
필터 지우기

Replace Cell Array with other Cell Array

조회 수: 2 (최근 30일)
Angga Lisdiyanto
Angga Lisdiyanto 2016년 6월 30일
편집: Angga Lisdiyanto 2016년 6월 30일

Hi, i want to replace cell array with other cell array's value. In example :

cell_array_1 = { 'i', 'love', 'you', 'you', 'love';
                 'i', 'you', 'love', 'i', 'much';
                 'i', 'love', 'you', 'so', 'much';
                 'i', 'love', 'you', 'so', 'much'}
cell_array_2 = {  [], [], [], 'so', 'much';
                  [], 'love', 'you', 'so', []}

Then i want to get below result :

 array_result = 
'i' 'love' 'you' 'so' 'much'
'i' 'love' 'you' 'so' 'much'
'i' 'love' 'you' 'so' 'much'
'i' 'love' 'you' 'so' 'much'

So, the first & second rows in cell_array_1 is replaced by cell_array_2. Is that possible?

Thanks in advance.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 30일
a1 = { 'i', 'love', 'you', 'you', 'love';
'i', 'you', 'love', 'i', 'much'}
a2 = { [], [], [], 'so', 'much';
[], 'love', 'you', 'so', []}
idx=cellfun(@isempty,a2)
a2(idx)=a1(idx)
  댓글 수: 1
Angga Lisdiyanto
Angga Lisdiyanto 2016년 6월 30일
편집: Angga Lisdiyanto 2016년 6월 30일
Hi, thanks for answering.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by