Plotting nodes and edges on a graph

Hi,
I was just wondering how you be able to plot node points and lines to connect to each other, similar to the figure below and according to the conditions stated below.
I want it to be 51x51 with the first value starting from the bottom left corner and increasing towards the top left corner until the last node defined is total number of y values (51). Then it continues to the second column of nodes starting from 52 to 102 to the next column and vice versa in which it is repeated at every column until the very last node at the bottom right corner is defined as 2601 which is basically 51 multipled by 51.
I = imread('LN2wN.png');
imshow(I)

Risposte (1)

Steven Lord
Steven Lord il 19 Ago 2021

0 voti

One way is to make a graph or digraph object and plot it.

1 Commento

I was able to do one column of nodes but I can't seem to do it for the rest.
nelx = 50;
nely = 50;
grid = zeros((nely+1),(nelx+1));
points = 1:(nely+1)*(nelx+1);
for j=1:nely+1
for i=1:nelx+1
grid(i,j)=points((nely+1)*(j-1)+i);
end
end
G=digraph(1:1:nely,2:1:nely+1);
plot(G)
Any help?

Accedi per commentare.

Categorie

Scopri di più su Graph and Network Algorithms in Centro assistenza e File Exchange

Prodotti

Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by