how to get the list of data that is not sampled when datasample is used
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have used the following code to take a random sample (of 300 values) from a data set of a total of 475 values:
[rco, idxco] = datasample (Controlall(1,:), 300);
This has resulted in a 1x300 double called rco of the sampled data with a 1x300 doubled called idxco showing me which pieces of the original data have actually been sampled.
I want to now access the remaining 175 values of unsampled data and was wondering if there is a way to put them into some sort of array without manually going through and taking note of which of the original values have been sampled already and which have not? Is this possible?
0 commentaires
Réponse acceptée
Jan
le 27 Fév 2017
Modifié(e) : Jan
le 27 Fév 2017
[rco, idxco] = datasample (Controlall(1,:), 300);
missIndex = setdiff(1:size(Controlall, 2), idxco);
missValue = Controlall(missIndex);
or:
missIndex = true(1, size(Controlall, 2));
missIndex(idxco) = false;
missValue = Controlall(missIndex);
Here missIndex is a logical index vector, for the above version it is a vector of the indices. The 2nd version will be faster.
Or:
missValue = Controlall(1, :);
missValue(idxco) = [];
if you need the values only and not the indices.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!