MATLAB: Hold on not working with ezplot3

ezplot3

I'm not sure why the hold on is not working in this example.
syms t1 t2 t3
line1 = [0,0,0] + t1*[0,0,1];
line2 = [1,0,0] + t2*[0,0,1];
line3 = [0,1,0] + t3*[0,0,1];
hold on
ezplot3(line1(1),line1(2),line1(3))
ezplot3(line2(1),line2(2),line2(3))
ezplot3(line3(1),line3(2),line3(3))
hold off
Any clues?

Best Answer

Hi Sara, ezplot3() is written in such a way that it undoes the effect of any previously issued hold on command.
In this case you can use plot3()
t = linspace(0,1,300);
plot3(zeros(300,1),zeros(300,1),t);
axis([-2 2 0 2 0 2]);
grid on;
hold on;
plot3(ones(300,1),zeros(300,1),t,'r');
plot3(zeros(300,1),ones(300,1),t,'k');
legend('line1','line2','line3');