how to get the list of data that is not sampled when datasample is used
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Ross Johnston
 el 27 de Feb. de 2017
  
    
    
    
    
    Comentada: Ross Johnston
 el 27 de Feb. de 2017
            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 comentarios
Respuesta aceptada
  Jan
      
      
 el 27 de Feb. de 2017
        
      Editada: Jan
      
      
 el 27 de Feb. de 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.
Más respuestas (0)
Ver también
Categorías
				Más información sobre Matrix Indexing en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!