How to assign one variable value to another variable and sort out the variable with a loop?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    automycer
 el 14 de Jul. de 2016
  
    
    
    
    
    Comentada: automycer
 el 19 de Jul. de 2016
            Two variables: DataX and Sample Length of the vectors are same [n, 1]. The variable DataX has data values (double) and the variable Sample has 'n' values. The sample variable values are either 0 or 1. The question is, a function needs to be assigned which would hold the data values of DataX and assign to Sample. Furthermore, another array should be defined which would hold the values of DataX and assign the values to the position of Sample which has the value of 1. So, these '1' values with their respective original position containing the data from DataX should be stored in a different array.
0 comentarios
Respuesta aceptada
  Stephen23
      
      
 el 14 de Jul. de 2016
        
      Editada: Stephen23
      
      
 el 18 de Jul. de 2016
  
       output = DataX(Sample==1)
If you want a full working version:
N = 23;
DataX = randi(9,1,N);
Sample = randi([0,1],1,5);
output = DataX(Sample==1)
3 comentarios
  Stephen23
      
      
 el 18 de Jul. de 2016
				>> S = '00000111110000000111110000000111110000011110000001111';
>> C = regexp(S,'100','match');
>> [C{:}]
ans =
100100100100
Más respuestas (1)
Ver también
Categorías
				Más información sobre Numeric Types 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!