MATLAB: “Invalid handle.” Error while using “Plot3”.

errorplotplot3

ax = axes('Parent',customUserInterface,'Position',[.1 .5 .375 .4]);
hold on
for m=1:numOfAP
plot3(ax,Data(m).traj(:,1),Data(m).traj(:,2),Data(m).traj(:,3),'g','LineWidth',2)
hold on
grid on
end
hold on
The Error points to the line with "Plot3". What am I going wrong with? Thanks in advance.

Best Answer

subplot() removes any axes that it overlaps. Your subplot() has exactly the same Position as your axes() call, so the subplot axes is going to overlap the explicit axes() created, which will cause the specific axes to be deleted.