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

33 visualizaciones (últimos 30 días)
Omer Iqbal
Omer Iqbal el 10 de Feb. de 2022
Comentada: Cris LaPierre el 10 de Feb. de 2022
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

Respuestas (1)

Cris LaPierre
Cris LaPierre el 10 de Feb. de 2022
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 comentarios
Omer Iqbal
Omer Iqbal el 10 de Feb. de 2022
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 el 10 de Feb. de 2022
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by