MATLAB: How to get this plot to give me a line

collatzMATLABplotting

Hello,
I have a small issue with this code, it plots the collatz algo. Its only giving me dots and no line. How can I fix it?
clc, clear all
m=100;
A = zeros(1,m);
figure
for N = 1:m
A(N) = collatzSteps(N);%%stores amount of steps for each run
plot(N,A(N),'bo-','LineWidth',2,'MarkerSize',4)
hold on
end
hold off
Now, these following functions help run it
function L = collatzSteps(n)%%function returns only the number
%%of steps
y = n;
L = 0;
while n > 1
n = collatz(n);%%call the function collatz
y = [y n];
L = length(y)-1;%%number steps
end
and
function y = collatz(x)
y = x;
if mod(x,2)==0%%calculates only the next step
y = x/2;
else
y = x*3+1;
end

Best Answer

Have a look at animatedline. and remember to drawnow()