How to insert the missing number into the cell array?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Suppose that I have this
I=[3 5 6 8 10 11]
A={[3];[6;8];[];[11]}
How to find the missing number of I in A and insert that number into any position of A? for intance like:
A={[3];[6;8];[5];[10;11]}
4 Commenti
Akira Agata
il 14 Mag 2019
Modificato: Akira Agata
il 14 Mag 2019
One quick question:
How did you define the position of '10' in your cell array A?
Risposta accettata
KSSV
il 14 Mag 2019
I=[3 5 6 8 10 11] ;
A={[3];[6;8];[];[11]} ;
% get empty cell
idx = cellfun(@isempty,A) ;
A{idx} = setdiff(I,cell2mat(A))
11 Commenti
KSSV
il 14 Mag 2019
I=[3 5 6 8 10 11] ;
A={[3];[6;8];[];[11]} ;
% get empty cell
idx = cellfun(@isempty,A) ;
missing = setdiff(I,cell2mat(A)) ;
A{idx} = missing(1)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!