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.

16 Ansichten (letzte 30 Tage)
%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 Kommentare
Walter Roberson
Walter Roberson am 10 Nov. 2021
https://www.mathworks.com/matlabcentral/answers/333163-error-when-running-g-graph-s-t-in-matlab#comment_1826524
has the solution.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Networks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by