You cannot create a line with arbitrary length. You have to decide for a specific start- and end-point.
nx = x2 - x1;
ny = y2 - y1;
nz = z2 - z1;
len = 1000;
xx = [x1 - len*nx, x2 + len*nx];
yy = [y1 - len*ny, y2 + len*ny];
zz = [z1 - len*nz, z2 + len*nz];
H = plot3(xx, yy, zz);
set(H, 'XLimInclude', 'off', 'YLimInclude', 'off', 'ZLimInclude', 'off');
Best Answer