I managed to get something close. It isn't as symetric as I'd like thought.
clc;clear;close all
% Plot data to be used in aspiration calculation
n = 35;
X = linspace(-5,5,n)';
Y = linspace(-5,5,n)';
[X,Y] = meshgrid(X,Y);
P = [X(:) Y(:)];
% Create points for line
x1=-1.522; x2=1.847;
y1=-0.761; y2=0.4344;
coefficients = polyfit([x1, x2], [y1, y2], 1);
a = coefficients (1);
b = coefficients (2);
xvals = linspace(-5,5,5*n); % x values that will be used to calculate y values. Can be
yvals = a*xvals+b;
PQ = [xvals(:) yvals(:)];
k = dsearchn(P,PQ)
% Plot
figure
scatter(X(:),Y(:),'red'); hold on;
scatter(X(k),Y(k),'green')
% scatter(X(k),Y(k),'blue')
title('Grid of data and intersecting line')
xlabel('mm')
ylabel('mm')
line(xvals,yvals)
grid on
axis equal