how to get the list of data that is not sampled when datasample is used
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jan
2017년 2월 27일
편집: Jan
2017년 2월 27일
[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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!