Overwrite table data if the logical index of row is true.
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Smithy
 el 26 de Ag. de 2022
  
    
    
    
    
    Comentada: Smithy
 el 26 de Ag. de 2022
            Hello everybody,
I would like to overwrite the table data if the logical index of row is true.
Logical index will be ture if sampleinput.TEST_ITEM1 is'TV'
Then, the sampleinput.TEST_LOAD1 need to be changed with sampleinput.TEST_LOAD0
If sampleinput.TEST_ITEM1 is not 'TV' and then keep sampleinput.TEST_LOAD1 data.
Please give me some help. 
load sample
k = contains(sampleinput.TEST_ITEM1,'TV');    % logical indexing
sampleinput.TEST_LOAD1(k) = sampleinput.TEST_LOAD0(k);

0 comentarios
Respuesta aceptada
  Chunru
      
      
 el 26 de Ag. de 2022
        load(websave("sample.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1108480/sample.mat"))
sampleinput
idx = sampleinput.TEST_ITEM1 == "TV";
sampleinput.TEST_LOAD1(idx) = cellstr(string(sampleinput.TEST_LOAD0(idx)))
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!

