How to sort string in a list of edit box based on a toggle buttons for each of them?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jacob Schoeb
 el 9 de Abr. de 2017
  
    
    
    
    
    Comentada: Walter Roberson
      
      
 el 10 de Abr. de 2017
            I am currently working on a creating a to-do list and I am stuck on sorting my values and strings of other uicontrols. I created a list of edit boxes with GUIDE and each of them has a toggle box for importance, checkbox and due date entry. When the user pushes it down it just identifies that the correlating edit box and etc are important. I want to be able to sort this information. Such as, if there are multiple toggle boxes pushed down, I want them to be moved to the top of the list. So basically, I need to swap the information between the top ones that are not toggled between the ones toggled.
I have attached a picture of what the guide looks like below:

2 comentarios
  Stephen23
      
      
 el 9 de Abr. de 2017
				
      Editada: Stephen23
      
      
 el 9 de Abr. de 2017
  
			+1 for using a sensible date format!
Question for clarity: you have multiple sets of "Entry" + "Due Date" + button + check box, and you want to physically rearrange their order based on the button status?
This is certainly possible, but would not be a typical action.
Respuesta aceptada
  Walter Roberson
      
      
 el 9 de Abr. de 2017
        Create four vectors of handles, one for Entries, one for Due Date, one for the toggle buttons, one for the check boxes.
get() the String properties of the Entries vector, and Due Date vector, and get() the Value properties of the toggle buttons vector, and check boxes vector. This will give you cell arrays.
Convert the Value cell array to matrix. sort() with 'stable' property, returning the indices as well as the values.
Index the other cell arrays at the indices returned by the sort(), getting out cell arrays that have been re-ordered according to the Important property.
set() the String properties of the Entries handles to the adjusted cell array, likewise for Due Date; likewise set() the Value properties of the other two vectors as appropriate.
7 comentarios
  Walter Roberson
      
      
 el 10 de Abr. de 2017
				EntryEditsVString = get(EntryEditsV, {'string'});
DueDateEditsVString = get(DueDateEditsV, {'string'});
ImportantTogglesVValue = get(ImportantTogglesV, {'value'});
CheckboxesVValue = get(CheckboxesV, {'value'});
... now do the sorting, producing IndexC. Then
   ReorderCheckboxes = CheckboxesVValue(IndexC);
   ReorderEntryEdits = EntryEditsVString(IndexC);
   ReorderDueDateEdits = DueDateEditsVString(IndexC);
   ReorderImportantToggles = ImportantTogglesVValue(IndexC);
   set( DueDateEditsV, {'String'}, ReorderDueDateEdits);
   set( EntryEditsV, {'String'}, ReorderEntryEdits);
   set( CheckboxesV, {'Value'}, ReorderCheckboxes);
   set( ImportantTogglesV, {'Value'}, ReorderImportantToggles);
Más respuestas (0)
Ver también
Categorías
				Más información sobre Shifting and Sorting Matrices 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!


