How to trim a data to same dimension?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
AbelM Kusemererwa
il 15 Lug 2015
Commentato: Guillaume
il 15 Lug 2015
Data contains 2 columns (plan and T). However, plan contains some NaN. I would like to delete the NaN from plan and also its corresponding values in T so that the good data from columns plan and T will be of the same dimension
0 Commenti
Risposta accettata
Guillaume
il 15 Lug 2015
Assuming data is an m x 2 matrix, it's simply:
Data(isnan(Data(:, 1)), :) = []
That is, find the nan in the first column of Data ( isnan(Data(:, 1))), and removes all the rows for which isnan is true ( Data(trueorfalse, :) = [])
4 Commenti
Guillaume
il 15 Lug 2015
Then you don't delete, you only copy the data you want to keep (everything that is not nan)
tokeep = ~isnan(plan); %use ~ for logical not
newplan = plan(tokeep);
newT = T(tokeep);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical 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!