How can I create a matrix from the nodes-edges-graph?
조회 수: 10 (최근 30일)
이전 댓글 표시
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165307/image.jpeg)
댓글 수: 0
답변 (1개)
Stephen Jue
2017년 6월 21일
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
Jay Vaidya
2020년 1월 1일
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. ![7.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257807/7.jpeg)
![7.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257807/7.jpeg)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!