How can I create a matrix from the nodes-edges-graph?
8 views (last 30 days)
Show older comments
I am doing my master thesis and I need to create a design-structure matrix automatically. I want to have this function: I define the interaction of the features first and then automatically create the graph(see below) and the matrix. How can I realize this function? Thx.
PS: DSM is like N-Square matrix, which show the interaction of the features. It's simpler because it's binary. The elements are either 0 or 1, means relevant or irrelevant.
0 Comments
Answers (1)
Stephen Jue
on 21 Jun 2017
This code demonstrates how to create an adjacency matrix (or DSM) from a graph, then plot a heatmap of the matrix:
s = [1 1 1 2 2 3];
t = [2 3 4 5 6 7];
G = digraph(s,t)
figure
subplot(1,2,1)
plot(G)
A = adjacency(G);
subplot(1,2,2)
heatmap(A)
1 Comment
Jay Vaidya
on 1 Jan 2020
Dear Mr Stephen,
I am having the similar problem, https://www.mathworks.com/matlabcentral/answers/498570-how-to-convert-the-graph-below-in-to-heatmap here. It would be really great if you could help me with this.
I have been putting questions for this as if you see this thread https://www.mathworks.com/matlabcentral/answers/498447-how-can-i-convert-2-column-matrix-to-a-cell-array This thread was made for the same question. My ultimate goal is to transform,
matrix->graph->adjacency matrix-> heatmap. My ultimate goal is to plot a heatmap from the input matrix. The input matrix is fig a (below). The goal is heatmap which I guess will need fig c. When I use a couple of solutions provided, I dont find the SizeX and SizeY in fig b and fig c to be matching. But I need it to be matched so that I can just represent the graph in form of a heatmap. Thanks in advance. Happy new year 2020.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!