Unable to use a value of type graph as an index.

33 次查看(过去 30 天)
Hi!
I am getting the error in below codes. I have all the inputs in workspace but I am still getting this error. Can anybody help me to resolve this error? Please find the screeshot of an error in an attachment.
for i=1:m
current_node = neigh_nodes_deg_2(i,1);
preceding_node = origin_node;
edge_path = [origin_node;current_node];
counter = 1;
% note: if the graph contains a closed sub-graph, the while loop will
% not end. Stop, identify the loop and correct it within the
% shapefile
while isempty(neigh_nodes_deg_2(G2,current_node,preceding_node))~=1
succeeding_node = niegh_nodes_deg_2(G2,current_node,preceding_node);
preceding_node = current_node;
current_node = succeeding_node;
edge_path = [edge_path; current_node];
counter = counter + 1;
end

回答(1 个)

Cris LaPierre
Cris LaPierre 2022-2-10
Your variable G2 is a graph obejct, but you are using it to index the first position (rows) of neigh_nodes_deg_2, which is a vector.
% vv Here
while isempty(neigh_nodes_deg_2(G2,current_node,preceding_node))~=1
  2 个评论
Omer Iqbal
Omer Iqbal 2022-2-10
Hi!
Thanks for your suggestions. Did you mean to change the order of variable is the solution? For instance, see below;
while isempty(neigh_nodes_deg_2(current_node,G2, preceding_node))~=1
However, it is still giving me an error by re arrangment of variables.
Cris LaPierre
Cris LaPierre 2022-2-10
You cannot use G2 as an index at all, It is not the value you think it is. Here is an example of the error.
A=1:3;
p=plot(A);
% your error
A(p)
Unable to use a value of type matlab.graphics.chart.primitive.Line as an index.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by