필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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
Guillaume
Guillaume 2018년 4월 26일
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 2018년 4월 30일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2018년 4월 30일
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
phdcomputer Eng
phdcomputer Eng 2018년 5월 7일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by