How to compare the relationship of two matrix from different excel?
Afficher commentaires plus anciens
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.
Réponses (1)
Chetan
le 30 Août 2023
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:
- Graph with undirected edges - MATLAB - MathWorks India
- Neighbors of graph node - MATLAB neighbors - MathWorks India
Hope it Helps !!
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!