How to use logical expressions to change the values of a column who matches a condition on a different column?
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Philippe Corner
 el 13 de Feb. de 2018
  
    
    
    
    
    Comentada: Philippe Corner
 el 23 de Mzo. de 2018
            If we have a matrix M like
V1.         V2.         V3.
1           1           1
2           4           9
3           4           0
4           4           3
5           5           1
6           9           5
7           0           3
8           4           5
9           4           6
10          5           2
How could we make zero the values of V2 and V3 which are from 4 to 7? obtaining M2 like:
V1.         V2.         V3.
1           1           1
2           4           9
3           4           0
4           0           0
5           0           0
6           0           0
7           0           0
8           4           5
9           4           6
10          5           2
0 comentarios
Respuesta aceptada
Más respuestas (1)
  Andrei Bobrov
      
      
 el 13 de Feb. de 2018
        >> V = [1     1
     4     9
     4     0
     4     3
     5     1
     9     5
     0     3
     4     5
     4     6
     5     2];
>> V(4:7,:)=0
V =
     1     1
     4     9
     4     0
     0     0
     0     0
     0     0
     0     0
     4     5
     4     6
     5     2
>>
Ver también
Categorías
				Más información sobre NaNs 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!


