how to set matrix from data

1 次查看(过去 30 天)
I have a path from node 6 to node 2, how can i can get the matrix like this [0 1 0 0 0 -1] ?

采纳的回答

Walter Roberson
Walter Roberson 2016-10-15
sn = 6; en = 2;
m = zeros(1, max(sn,en));
m(sn) = -1;
m(en) = 1;
  2 个评论
yu yue
yu yue 2016-10-15
编辑:yu yue 2016-10-15
hi. If I have 6 node, but the path is from 3 to 5, how can I get [0 0 -1 0 1 0]? I only get [0 0 -1 0 1]

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by