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 日

0 投票

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]
Walter Roberson
Walter Roberson 2016 年 10 月 15 日
m = zeros(1,6);

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by