Filling missing points in a grid

3 views (last 30 days)
Hi everyone
I am wondering if anyone can help to mark the missing points on the grid with (x) . I have a regular points in x,y that I get from executing the differences between a predeifined points to get the grid, at the same time, some points are missing and I want to mark them (x red) as shown in the figure (i.e, (7,8), and the other missing points. How to select specific range of points with their index as marked in the black sqaure .
I have execute the code
M=3; N=4;
[xx yy]=meshgrid(mN, mN);
[x y]=meshgrid(nM, nM);
L1= union(L1, L2, 'rows');
plot(S(:, 1),S(:,2) ,'o','color', 'b', 'markersize',4, 'linewidt',1);
LEN_S = size(S, 1);
MAX_x = max(S(:, 1));
MIN_x = min(S(:, 1));
MAX_y = max(S(:, 2));
MIN_y = min(S(:, 2));
[mx_mat, my_mat] = ndgrid(-(MAX_x - MIN_x):(MAX_x - MIN_x), -(MAX_y - MIN_y):(MAX_y - MIN_y));
mx_vec = mx_mat(:); my_vec = my_mat(:);
w = zeros(size(mx_vec));
n1 = cell(size(mx_vec));
n2 = cell(size(mx_vec));
for ii = 1 : size(S, 1)
for jj = 1 : size(S, 1)
index = (mx_vec == S(ii, 1) - S(jj, 1) & my_vec == S(ii, 2) - S(jj, 2));
w( index ) = w( index ) + 1;
n1{ index } = [n1{ index }; S(ii, :)];
n2{ index } = [n2{ index }; S(jj, :)];
D = [mx_vec, my_vec];
LEN_S = size(S, 1);
SS = repmat(S, [LEN_S, 1]);
SS_= kron(S, ones(LEN_S, 1));
[D1, ~, ind_SS] = unique(SS - SS_, 'rows', 'sorted');
fh2= figure (2);
plot(D1(:,1), D1(:,2) ,'square','color', 'r', 'markersize',5, 'linewidt',2);hold on
plot(D1(:,1), D1(:,2) ,'square','color', 'b', 'markersize',5, 'linewidt',2);hold on
axis([-inf inf -inf inf ]);
I apperciate any help

Accepted Answer

Doddy Kastanya
Doddy Kastanya on 5 May 2021
You could try to add the following at the end of your code:
hold on
If there are other points, then you could embed this in a for loop identifying the appropriate x and y position.

More Answers (0)


Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!