Filter löschen
Filter löschen

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

24 Ansichten (letzte 30 Tage)
Omer Iqbal
Omer Iqbal am 10 Feb. 2022
Kommentiert: Cris LaPierre am 10 Feb. 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

Antworten (1)

Cris LaPierre
Cris LaPierre am 10 Feb. 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 Kommentare
Omer Iqbal
Omer Iqbal am 10 Feb. 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 am 10 Feb. 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.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by