How can I create a Graph with specific coordinates?

58 ビュー (過去 30 日間)
Paula González Díaz
Paula González Díaz 2020 年 7 月 27 日
Hello,
I have two vectors (6,1), one for X coordinates and the other for the Y coordinates. I want to use the function Graph to create a graph that join each (x(i),y(i)) in a specific way, in this case:
s=[1,2,5,5,5,5,6,6,6,6]
t=[3,4,1,2,3,4,1,2,3,4]
graph(s,t)
I don't know how to locate the vertices in my specifc coordinates, If anyone know how to do it I would be grateful.
Thank you so much.

回答 (1 件)

Steven Lord
Steven Lord 2020 年 7 月 27 日
When you call plot on your graph you can specify the X, Y, and Z coordinates of the nodes. See the "Custom Graph Node Coordinates" example on the documentation page for the plot for graph objects.
If you want to keep the graph and the coordinate data together, add the coordinates as additional attributes on the graph object.
  2 件のコメント
Paula González Díaz
Paula González Díaz 2020 年 7 月 28 日
Thank you, but my problem is that I want to create a kind of 'shortest path' optimization program so I think I need to use the Graph function instead of plot but I want every vertice in a specific coordinate position and I don't know if graph can do that.
Frederik Dush Santush Koshta
Frederik Dush Santush Koshta 2021 年 11 月 22 日
Did you find a solution to this problem @Paula González Díaz?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by