Need to fill out skipped rows in a matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Davis Philip Reina-Guerra
am 7 Okt. 2022
Kommentiert: Davis Philip Reina-Guerra
am 7 Okt. 2022
I have a data analysis code which spits out values by experimental trials 1-10. The problem is that some trials (by design) do not produce a value, meaning some of the data is "complete" and some is "partial". I need help filling out the partial data with the missing trials so that all data matrices are 10x2 and it is straightforward to perform operations on them.
I think this example illustrates my point best. How do I approach this? Even just links to relevant documentation would help a ton, I am still fairly new to the MATLAB universe

0 Kommentare
Akzeptierte Antwort
Davide Masiello
am 7 Okt. 2022
Bearbeitet: Davide Masiello
am 7 Okt. 2022
Take this example
complete = [(1:10)',rand(10,1)]
partial = [sort(randperm(10,6))',rand(6,1)]
You can apply the following to you dataset.
missing_n = ~any(partial(:,1) == 1:10,1)
newpartial = zeros(size(complete));
newpartial(missing_n,:) = [find(missing_n)',nan(nnz(missing_n),1)];
newpartial(~missing_n,:) = partial;
partial = newpartial
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!