Add missing rows to a list in a cell array
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Raúl García Odriozola
il 29 Giu 2023
Commentato: Raúl García Odriozola
il 29 Giu 2023
I have a cell array with values like this
...
9 [10370;10371;10372]
10 [12933;12934]
11 10001
12 11320
13 [11347;11348]
14 [10362;10363]
17 [12632;12633]
...
And i want to add blank rows for all the missing numbers in the first collumn so it would look like this
...
9 [10370;10371;10372]
10 [12933;12934]
11 10001
12 11320
13 [11347;11348]
14 [10362;10363]
15
16
17 [12632;12633]
...
I have a list of how many items should appear on the first row but i'm having problems finding a way without using a for loop, the list is too big for that.
0 Commenti
Risposta accettata
cdawg
il 29 Giu 2023
Will this work?
m = {...
9 [10370;10371;10372]
10 [12933;12934]
11 10001
12 11320
13 [11347;11348]
14 [10362;10363]
17 [12632;12633]};
inds = cell2mat(m(:,1));
lastRow = 20;
M = cell(lastRow,2);
M(inds,2) = m(:,2);
M(inds,1) = m(:,1)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!