Filter löschen
Filter löschen

Plotting Graph from Struct

1 Ansicht (letzte 30 Tage)
Isaac Osei Agyemang
Isaac Osei Agyemang am 11 Okt. 2018
Please can someone help me plot a graph from the attached mat file.

Akzeptierte Antwort

Guillaume
Guillaume am 11 Okt. 2018
Bearbeitet: Guillaume am 11 Okt. 2018
We could have done with an explanation of what the fields of your structure actually represent.
Assuming that the field A is the adjacency matrix of your graph (you really should have told us that), then:
matcontent = load('dolphins.mat');
network = graph(matcontent.Problem.A, cellstr(matcontent.Problem.aux.nodename));
plot(network);
See the documentation of graph.plot for the various plotting options as the default plot is quite messy. In particular, you may want to play with the 'Layout' option.
edit: fixed typo in nodename
  3 Kommentare
Guillaume
Guillaume am 11 Okt. 2018
It was an obvious typo of the name of one your variables which you should have spotted yourself:
network = graph(matcontent.Problem.A, cellstr(matcontent.Problem.aux.nodename));
plot(network);
Isaac Osei Agyemang
Isaac Osei Agyemang am 11 Okt. 2018
Thanks, this the outcome I was expecting. Thanks Guillaume.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by