how do i number all nodes in a graph

4 views (last 30 days)
Anusha Venkapally
Anusha Venkapally on 10 Jul 2016
Edited: KSSV on 11 Jul 2016

hello.. i am a beginner in matlab. i have a matlab code which plots a graph. please help me in numbering all the points(nodes) in the graph. here is my matlab code. "Nodes3.txt" is file with all the nodes that are to be plot.

clc
clear all
close all
load Elements3.txt
load Nodes3.txt
nrelm=size(Elements3,1);
nnod=size(Nodes3,1);
Edof=zeros(nrelm,4);%
Ex=zeros(nrelm,3); Ey=Ex; Ez=Ex;
Edof(:,1)=sort(1:nrelm);
Elm(:,1)=sort(1:nrelm);
for i=1:nrelm
    Edof(i,2:7)=[2*Elements3(i,6)-1 Elements3(i,6)*2 2*Elements3(i,7)-1 ...
        Elements3(i,7)*2 2*Elements3(i,8)-1 2*Elements3(i,8)];  
    Elm(i,2:4)=Elements3(i,6:8);  
    Ex(i,:)=[Nodes3(Elm(i,2),2) Nodes3(Elm(i,3),2) Nodes3(Elm(i,4),2)];
    Ey(i,:)=[Nodes3(Elm(i,2),3) Nodes3(Elm(i,3),3) Nodes3(Elm(i,4),3)];
    Ez(i,:)=[Nodes3(Elm(i,2),4) Nodes3(Elm(i,3),4) Nodes3(Elm(i,4),4)];    
end
nrdof=max(max(Edof));
figure(1);
hold on;
for i=1:length(Edof(:,1));
    plot(Ex(i,[1:end 1]),Ey(i,[1:end 1]));
end
axis equal

Accepted Answer

KSSV
KSSV on 11 Jul 2016
Edited: KSSV on 11 Jul 2016
Use the PlotMesh code from the below link:
To display the node numbers, you un comment the lines at the end of the code which says; To display the node numbers. Alternatively have a look on the below code as well:

More Answers (0)

Community Treasure Hunt

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

Start Hunting!