Replace Cell Array with other Cell Array
1 次查看(过去 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.
0 个评论
采纳的回答
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!