How to compare the relationship of two matrix from different excel?

3 次查看(过去 30 天)
Hi All,
Please help me, I have a concern about if sheet1 have the matrix contain binary value (show the relation between the variable) and sheet2 have numerical value,
1) how to show that sheet2 will follow the relation show in the sheet1
2) add the value of related variable in sheet2
Its possible? I am very much a beginner to Matlab,I need your suggestion.
Thank you for your time.
  2 个评论
KSSV
KSSV 2022-9-7
To load the data from excel to matlab use readtable. Rest we can help on seeing how the data is.
Nurul Hidayah Mohd Nor
Thank you for your suggestion. I already load the data using the readtable, but cannot figure out how to or what function that I should use to connect between those two sheet so that i see the relationship

请先登录,再进行评论。

回答(1 个)

Chetan
Chetan 2023-8-30
Based on my understanding, your sheet1 represents the adjacency matrix between the locations. You need to perform calculations based on the relationship. So, you can create a graph from the matrix and then use graph functions, such as neighbors, to find the connected neighbors. You can efficiently perform your calculations by using the indices of those neighbors.
Here is the sample code for the neighbors function:
% Step 1: Load the relation matrix from the Excel sheets
matrix = xlsread('Sheet1.xlsx', 'Sheet1');
% Step 2: Create a graph object using the relation matrix
G = graph(matrix);
% Step 3: Find the neighbors of the specified location
neig= neighbors(G, 1);
disp('Neighbors of the specified location:');
disp(neig);
You can refer to the following articles for more details about the graph:
Hope it Helps !!

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by