How to use get and set to remove the last value of a string in a text uicontrol?
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    theblueeyeswhitedragon
 el 11 de Abr. de 2018
  
    
    
    
    
    Respondida: Walter Roberson
      
      
 el 11 de Abr. de 2018
             function script4()
fig = figure('units', 'pix', 'position', [300, 300, 300, 300], 'menubar','none','resize', 'off');
pushbuttonh = uicontrol('style', 'pushbutton', 'unit', 'normalized', 'position', [0.3, 0.075, 0.4, 0.1], 'string', 'Clear one character', 'Callback', @pushbuttonh_Callback);
edittexth = uicontrol('style', 'text', 'unit', 'normalized', 'position', [0.1, 0.3, 0.8, 0.5], 'string', 'This is the string');
function pushbuttonh_Callback(source, event)
  currentChar = get(edittexth, 'String');
  if ~isempty(currentChar)
     set(edittexth, 'String', edittexth(1:end-1));
  else 
    set(editexth, 'String', 'There is nothing to delete');
end
end
end
0 comentarios
Respuestas (1)
  Walter Roberson
      
      
 el 11 de Abr. de 2018
        You should be subscripting the current characters not the handle.
0 comentarios
Ver también
Categorías
				Más información sobre String Parsing 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!

