MATLAB can relabel graph node table columns but not edge table columns.

2 Ansichten (letzte 30 Tage)
It seems that I can rename a column in the Nodes table of a graph but trying to do so for the Edges table returns an error. (This is a minimal example. It has come up in a method I'm trying to write for a user-defined class.)
g=digraph([1 2],[2 2]);
g.Nodes.label={'A';'B'}
g =
digraph with properties: Edges: [2×1 table] Nodes: [2×1 table]
g.Nodes = renamevars(g.Nodes,'label','Label')
g =
digraph with properties: Edges: [2×1 table] Nodes: [2×1 table]
g.Edges.label={'A';'B'}
g =
digraph with properties: Edges: [2×2 table] Nodes: [2×1 table]
g.Edges = renamevars(g.Edges,'label','Label')
Error using digraph/subsasgn>assignToEdges
Direct editing of edges not supported. Use addedge or rmedge instead.

Error in indexing (line 14)
G = assignToEdges(G, S, V);

Akzeptierte Antwort

Jinal
Jinal am 17 Mär. 2023
Bearbeitet: Jinal am 17 Mär. 2023
Hi Roy,
I understand that you are facing issues while using ‘renamevars’ to rename a column in 'g.Edges'.
You can use the following command to rename the column.
g.Edges.Properties.VariableNames("label") = "Label";
Please refer this page for more information.
Hope this helps.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by