Effacer les filtres
Effacer les filtres

Replace Cell Array with other Cell Array

2 vues (au cours des 30 derniers jours)
Angga Lisdiyanto
Angga Lisdiyanto le 30 Juin 2016

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.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 30 Juin 2016
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 commentaire
Angga Lisdiyanto
Angga Lisdiyanto le 30 Juin 2016
Modifié(e) : Angga Lisdiyanto le 30 Juin 2016
Hi, thanks for answering.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by