MATLAB: How to plot point x on a line

plot

i am new in matlab i want to highlight point intersection point on a line in graph i can plot a point but not able to plot the point on line my code is here:
function[ x y]= test (x1,y1,x2,y2)
y=((-x1)+y1*(y2-y1))/(x2-x1);
x=((-y1*(x1-x2))/(y1-y2))+x1;
plot(x,y,'ro')
end

Best Answer

I agree that the question is a bit unclear.
If you're wondering how to find and highlight the intersection point(s) between two curves this below code snippet might be helpful:
x1 = [1 2 3 4]; y1 = [0 2 4 6];
x2 = [1 2 3 4]; y2 = [6 4 2 0];
% find intersection
[x_intsect, y_intsect] = polyxpoly(x1, y1, x2, y2)
% plot everything on a single figure
figure;
hold on;
plot(x1, y1, 'k-', x2, y2, 'r-');
plot(x_intsect, y_intsect, 'bo');
hold off;
Related Question