In 3D your (x,y) points remain same on the line and your z coordinate will vary. You can write a small function for you need.
Example
[X,Y,Z] = peaks(50) ;
n = 10 ;
x = 0 ; y = 0 ; % want line passing throuh (0,0) and parallel to z axies
P = [repmat(x,10,1) repmat(y,10,1) (0:9)'] ;
surf(X,Y,Z)
shading interp
hold on
plot3(P(:,1),P(:,2),P(:,3))