How to extract data from a table and input the wanted values into a new one?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I need to go through a table and find values >= 50, and then take those values, match them to their month, and create a new output containing the month
1 comentario
  dpb
      
      
 el 24 de Jun. de 2020
				See last section on logical indexing @ https://www.mathworks.com/help/matlab/math/array-indexing.html
Respuestas (1)
  Kavya Vuriti
    
 el 30 de Jun. de 2020
        Hi,
As mentioned, you can try using logical indexing. Assuming T is the table, first column in the table as month and second column in the table as values, here is the sample code:
monthsfromtable = table2array(T(:, 1)); % Convert months data in table to array
valuesfromtable = table2array(T(:, 2)); % Convert values data in table to array
idx = valuesfromtable >= 50; % Logical indexing to get values greater than or equal to 50
requiredValues = valuesfromtable(idx); % Values greater than or equal to 50
requiredMonths = monthsfromtable(idx); % Months with values greater than 50
valuesJan = requiredValues(strcmp(requiredMonths, 'Jan')); % Values in Jan month greater than 50
0 comentarios
Ver también
Categorías
				Más información sobre Logical 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!


