필터 지우기
필터 지우기

Check for incorrect argument data type or missing argument in call to function 'neighbors'.

조회 수: 3 (최근 30일)
Hi! I am having an error on the following functions. I have all the inputs but the fucntion is still not able to read it.Please see the snapshot
j=1;
for i=1:numel(M_nodes_idx)
% disp(i)
current_node = M_nodes_idx(i,1);
if neighbors(current_node,g)~=current_node
n1n2 = neighbors(g,current_node);
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2022년 1월 9일
What are the values of g and current_node when you get this error? See the page Debug MALTAB Code Files if you are not sure how to get these values.
Omer Iqbal
Omer Iqbal 2022년 1월 9일
Th value of current mode is 1, while g has all edges and nodes. I am trying to understand the problem through debuding but the problem does not seems to be clear becasue I have all the inputs and the fucntion should be working.

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2022년 1월 11일
@Star Strider had what I thought was the correct answer. In your if statement, you reverse the order of your inputs to neighbors.
g should be your graph object (e.g. g = graph(bucky);), which we can't see, so check that, and nodeID should be a single node (e.g. current_node)
% v This should be the first input to neighbors
if neighbors(current_node,g)~=current_node
n1n2 = neighbors(g,current_node);
Try correcting the order of your inputs.
if neighbors(g,current_node)~=current_node
n1n2 = neighbors(g,current_node);
  댓글 수: 2
Omer Iqbal
Omer Iqbal 2022년 1월 12일
Thank you so for your suggestions. I have tried to change the order but I am still getting the same error mentioned above.
When I looked into g( 1*1 graph) , I have found that it has two parts , one is edges while second is Nodes. The edges has values in it while Nodes doesnot have any value in it. I have used the follwoing codes to generate g. I am not sure why it is not computing the Nodes in g. Please snapshot and codes below;
for i=1:numel(EndNodes(:,1))
%disp(i)
if numel(EndNodes{i,1}{1,1})>1
EndNodes{i,1}{1,1} = min (EndNodes{i,1}{1,1});
end
EndNodes2(i,1)=EndNodes{i,1}{1,1};
if numel(EndNodes{i,1}{1,2})>1
EndNodes{i,1}{1,2} = min (EndNodes{i,1}{1,2});
end
EndNodes2(i,2)=EndNodes{i,1}{1,2};
end
% creating and empty graph and assigning edges to it
g=graph();
g = addedge(g,EndNodes2(:,1),EndNodes2(:,2));
Cris LaPierre
Cris LaPierre 2022년 1월 12일
Please share all your code. You can attach your script using the paperclip icon.

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

Community Treasure Hunt

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

Start Hunting!

Translated by