How do I add new imroi objects to an array?
    7 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Hasan Aslam
 il 17 Dic 2015
  
    
    
    
    
    Modificato: Hasan Aslam
 il 21 Dic 2015
            At the moment, I am creating new imroi objects manually like so:
line1 = imline(main_axes, [1 2], [1 2], ...
                        'PositionConstraintFcn', constraint_line);
line2 = imline(main_axes, [2 3], [2 3], ...
                        'PositionConstraintFcn', constraint_line);
line3 = imline(main_axes, [3 4], [3 4], ...
                        'PositionConstraintFcn', constraint_line);
However, what I really want is to store the imroi objects in an array. Something a bit like this:
line_objects(line1, line2, line3)
Then my objective is to use this to add line objects from the press of a button like so:
line_button = uicontrol('style', 'pushbutton',...
                  'string', 'Add a line', ...
                  'callback', {@add_line, line_objects});
Can anyone give some general advice on how to approach this?
0 Commenti
Risposta accettata
  Rebecca Krosnick
    
 il 21 Dic 2015
        My understanding is that you would like to use the "line_objects" variable across callbacks in your GUI. Rather than trying to pass a "line_objects" variable around as an argument to "add_line", I suggest sharing the variable using "setappdata"/"getappdata" or "guidata". The following link provides an overview of different approaches for sharing data in GUIs as well as examples: http://www.mathworks.com/help/matlab/creating_guis/share-data-among-callbacks.html
1 Commento
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Environment and Settings in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!