For demo purposes, I've made a little class that streams live data from some other software I programmed via TCP and I'd like to plot the incoming data as a 3D mesh or surface. The code looks something like this:
c = MyClient( 'localhost', 5555 );
c.connect();
ButtonHandle = uicontrol('Style', 'PushButton', ...
'String', 'Stop loop', ...
'Callback', 'delete(gcbf)');
while true
if ~ishandle(ButtonHandle)
fprintf( 'Loop stopped by user\n' );
break;
end
[ret,m] = c.read();
if( ret == true )
surf( m );
zlim([0 1]);
else
pause( .05 );
end
end
I would like the value range to be constant, so I inserted zlim. This works fine, basically. Now when I add a colorbar, everything seems to become really slow. I'm not sure how the plotting works internally, but I thought maybe it's not meant to be used this way. My hypothesis is that the plot is created from scratch each loop. If that's true, is there a way of reusing the mesh and just update the values? If not, how would I do something like that in MATLAB?
I guess my overall question is what is a recommended way of plotting live data? I also noticed that when 3D rotating the plot, it jumps back to initial perspective all the time, so ideally I would like to have a mesh I can just update with new values. Is that even possible?
0 Comments
Sign in to comment.