how to get the list of data that is not sampled when datasample is used
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Jan
on 27 Feb 2017
Edited: Jan
on 27 Feb 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.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!