Effacer les filtres
Effacer les filtres

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

24 vues (au cours des 30 derniers jours)
Omer Iqbal
Omer Iqbal le 10 Fév 2022
Commenté : Cris LaPierre le 10 Fév 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

Réponses (1)

Cris LaPierre
Cris LaPierre le 10 Fév 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 commentaires
Omer Iqbal
Omer Iqbal le 10 Fév 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 le 10 Fév 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.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by