Clear Filters
Clear Filters

How to define cell arrays that their elements are extracted from a Dataset?

2 views (last 30 days)
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
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).
phdcomputer Eng
phdcomputer Eng on 30 Apr 2018
My input is an excel dataset which I attached to this comment. My desired output is to create an undirected weighted graph based on this excel dataset in Matlab. more explanation: Each node represents a stakeholder, the edge shows communication among two stakeholders and its weight indicates the total instance of communication between them. I will be grateful to have any similar examples or related link in this field.

Sign in to comment.

Accepted Answer

Guillaume
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
phdcomputer Eng
phdcomputer Eng on 7 May 2018
very grateful Yes, that's right but I just have the excel dataset as the input and I don't have weights matrix, Do you think it is possible to calculate weights matrix from excel dataset? the other problem is that this graph can be made for 30 rows of data but for more, I receive this error: Error in thefirefox100 (line 9) g = graph(t.Assignee, t.Reporter ); I'm very thankful for your great help.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import from MATLAB 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!