Error using matlab.int​ernal.grap​h.construc​tFromEdgeL​ist (line 249) Weight must have as many elements as edge list or be a scalar.

14 views (last 30 days)
lol
lol on 10 Nov 2021
Commented: lol on 13 Nov 2021
%THIS IS MY CODE:
filename = 'TABLA_AF1.xlsx';
s = xlsread(filename,'A2:A25');
t = xlsread(filename,'B2:B25');
weights = xlsread(filename,'C2:C25');
G = graph(s,t,weights);
p = plot(G,'EdgeLabel',G.Edges.Weight);
[T,pred] = minspantree(G);
highlight(p,T)
And the file Tabla_AF1.xlsx, contains this 3 rows:
Nodo Inicial Nodo Final Distancia
A B 2
A E 16
A C 3
C F 3
C I 12
F E 7
F I 9
F H 6
I H 14
E H 2
E G 4
B E 8
B D 11
D E 2
D G 5
D J 7
G J 1
G L 6
H G 3
J L 12
H L 17
I K 7
H K 9
K L 17
How can I fix it??? please
  3 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by