MATLAB: Struggling with line()

lineplot

Hi,
I am trying to plot a line using the line command:
code is the following
a = [0 0]; b = [40 0];
line(a,b, 'color', 'k','LineWidth',2)
However, when I plot I get a line from (0,0) to (0,40) like so:
I have absolutely no idea why this is happening and have tried running on a friend's computer to make sure I am not going crazy. Please let me know if there is a glaring issue here that I have missed or how I can fix this. Thanks in advance

Best Answer

The first parameter is a list of x coordinates. The second parameter is a list of y coordinates.
The parameters are not source xy pair and destination xy pair.