How to fix slow GUI plotting using axes(handles...)
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I have a gui with multiple plots updating through while loop once user presses 'Start' button. The issue I have is that gui is running really slow.. I ran a profiler, and it turns out that calling axes function (in order to access a specific figure within the gui panel) takes up the majority of time. Below is the sample code:
Any suggestions to not use axes inside the while loop to plot, or general suggestions to improve the speed of the gui will be really appreciated. Thanks in advance.
              function Start_Callback(hObject, eventdata, handles)
                   load('data.mat')
                   dataSegment = 1;
                   maxSegment = 1000;
                   %other set ups....
 time   calls line while (~stop && ~dataEnd)
 0.01      34  328     if ~isempty(detectedSpikes1_1) 
  3.05      34  329         axes(handles.axes6); 
  0.27      34  330         plot([1:spikeLength], detectedSpikes1_1,'r','linewidth',1); 
  3.14      34  331         axes(handles.axes29); 
  0.29      34  332         scatter(detectedSpikes1PC_1(1:length(detectedSpikes1_1(:,1)),1),detectedSpikes1PC_1(1:length(detectedSpikes1_1(:,1)),2),'r'); 
            34  333     end 
            34  334     if ~isempty(detectedSpikes1_2) 
  3.13      34  335         axes(handles.axes27); 
  0.07      34  336         plot([1:spikeLength], detectedSpikes1_2,'g','linewidth',1); 
  3.19      34  337         axes(handles.axes29); 
  0.29      34  338         scatter(detectedSpikes1PC_2(1:length(detectedSpikes1_2(:,1)),1),detectedSpikes1PC_2(1:length(detectedSpikes1_2(:,1)),2),'g'); 
            34  339     end 
            34  340     if ~isempty(detectedSpikes1_3) 
  3.15      34  341         axes(handles.axes28); 
  0.09      34  342         plot([1:spikeLength], detectedSpikes1_3,'b','linewidth',1); 
  3.23      34  343         axes(handles.axes29); 
  0.28      34  344         scatter(detectedSpikes1PC_3(1:length(detectedSpikes1_3(:,1)),1),detectedSpikes1PC_3(1:length(detectedSpikes1_3(:,1)),2),'b'); 
            34  345     end 
               end
0 comentarios
Respuestas (1)
  Walter Roberson
      
      
 el 17 de Mayo de 2015
        As we discussed in your previous question, keep the handles of the graphics objects and update them using set()
A scatterplot does not return a line object in any modern version: it returns a scatterplot object. However, the update method is very much the same, set() the XData and YData properties; see http://www.mathworks.com/help/matlab/ref/scatterseries-properties.html
0 comentarios
Ver también
Categorías
				Más información sobre Graphics Performance 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!

