How to define cell arrays that their elements are extracted from a Dataset?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
phdcomputer Eng
le 26 Avr 2018
Commenté : Walter Roberson
le 7 Mai 2018
I have two 29*1 cells in my Matlab workspace (they were two columns in my excel dataset with the names: Assignee & Reporter that I imported them to Matlab workspace as two cells). I attached my excel dataset here. my aim is to scroll these two cells by two counters (i & j ) and compare them in the way that if two reporters cell elements are similar while their assignee cell elements are not the same so these two Assignee elements will be two nodes in my graph and communicate by an edge. but there is a problem in defining the cells Assignee and Reporter. I wrote these lines:
load firefox.mat
s={};
t={};
G=graph(s,t);
%Assignee=table(Assignee); ???
Assignee=cell(); ???
Reporter=cell(); ???
for i=2:29 %my Dataset has 29 rows
for j=2:29
if Assignee(i)~=Assignee(j)
if Reporter(i)==Reporter(j)
s={Assignee(i)};
t={Assignee(j)};
g=graph(s,t);
break;
end
break;
end
end
end
Plot(G);
I'll be very grateful if suggest me what is the correct method for this problem?or how the lines must modify to create the graph correctly?
4 commentaires
Guillaume
le 26 Avr 2018
Again: give an example of inputs (attach the excel file for example) and desired output.
Undefined function or variable 'filename'. Seems pretty straightforward to solve. Create that filename variable (containing the path of the file).
Réponse acceptée
Guillaume
le 30 Avr 2018
I'm not very clear on what the edges and nodes in your graph should be. If the edges are defined simply by the pair Assignee and Reporter, then this is easily done:
t = readtable('firefox.xlsx');
g = graph(t.Assignee, t.Reporter);
plot(g); %to see the graph
4 commentaires
Walter Roberson
le 7 Mai 2018
I showed the calculation of the weights matrix in https://www.mathworks.com/matlabcentral/answers/397144-how-to-define-g-graph-s-t-weights-nodetable#comment_564523
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!