Search code examples
matlabmatlab-figurepoint-clouds

keep matlab view open after the function exits


I have a function that draws a point cloud. When I call the function, it shows the point cloud but as soon as the function exits, the view exits as well. How can I keep the view from exiting?

function drawPtCloud(ptCloud,colorLabels)
  player = pcplayer(xlimits, ylimits, zlimits);
  view(player, ptCloud,colorLabels);
end

Solution

  • The axes is actually saved in the output argument of pcplayer. Take the output argument of pcplayer, i.e. player, as an output argument of your custom function drawPtCloud. i.e.

    function player = drawPtCloud(ptCloud, colorLabels)
      player = pcplayer(xlimits, ylimits, zlimits);
      view(player, ptCloud,colorLabels);
    end