How to define cell arrays that their elements are extracted from a Dataset?
1 view (last 30 days)
Show older comments
phdcomputer Eng
on 26 Apr 2018
Commented: Walter Roberson
on 7 May 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 Comments
Guillaume
on 26 Apr 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).
Accepted Answer
Guillaume
on 30 Apr 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 Comments
Walter Roberson
on 7 May 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
More Answers (0)
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!