Why isn't my loop running? (using strcmpi, trying to find a handle for the text)
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    ilona
 am 10 Dez. 2013
  
    
    
    
    
    Kommentiert: ilona
 am 10 Dez. 2013
            Hello
Here is part of my code, I wanted to find an handle for the text... so I created a loop that runs all over the axis' children and looks for the text's handle.
    % code
%get text handle 
textH=get(axisH,'children')
for ii=1:length(textH)
if strcmpi(get(textH(ii),'type'),'text')
    textH=textH(ii)
end
end
%set text properties
set(textH,'color','b','FontSize',20)
why isn't my loop running?
0 Kommentare
Akzeptierte Antwort
  Jos (10584)
      
      
 am 10 Dez. 2013
        
      Bearbeitet: Jos (10584)
      
      
 am 10 Dez. 2013
  
      I don't know why your loop is not running. I suggest you try some debugging. Also you change the array you're looping over inside the loop, which is not good.
textH = get(axisH,'children') % should give a list of numbers
N = numel(textH) % I prefer numel over length
textH_KEEP = NaN
for ii = 1:N
  str = get(textH(ii),'type') % debug
  TF = strcmpi(str,'text') % debug
  if TF
    textH_KEEP = textH(ii)
  end
end
textH_KEEP % should be NaN when no text handles are found
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!