Filling missing points in a grid
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    fatoma Saml
 il 2 Mag 2021
  
    
    
    
    
    Modificato: fatoma Saml
 il 16 Ago 2021
            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;
  mN=[0:M-1]*N;
  nM=[0:N-1]*M;
[xx yy]=meshgrid(mN, mN);
[x y]=meshgrid(nM, nM);
L1=[xx(:),yy(:)]; 
L2=[x(:),y(:)];
LL=[0,0];
 L1= union(L1, L2, 'rows');
 S=union(L1,LL,'rows');
 figure
 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, :)];
        end
    end
    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
Thanks 
0 Commenti
Risposta accettata
  Doddy Kastanya
      
 il 5 Mag 2021
        You could try to add the following at the end of your code:
hold on
text(7,8,'X','color','r')
If there are other points, then you could embed this in a for loop identifying the appropriate x and y position.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su General Applications in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!