Fitting N(N-1) points on an NxN matrix

1 回表示 (過去 30 日間)
Vic
Vic 2012 年 12 月 1 日
Suppose I have an N(N-1) vector that corresponds to each non-diagonal entry of an NxN matrix. Is there anyway that I can encode that onto my matrix?
i.e. For n=3, given [ 2 3 4 5 6 7 ] we obtain
[0 4 6 ; 2 0 7 ; 3 5 0]?
  2 件のコメント
Nasser M. Abbasi
Nasser M. Abbasi 2012 年 12 月 1 日
編集済み: Nasser M. Abbasi 2012 年 12 月 1 日
If one posts same question here and at another forum at the same time, like comp.soft-sys.matlab, it is only right that you mention that and give a link. This way one does not waste their time if someone else already answered you on the other forum.
Vic
Vic 2012 年 12 月 1 日
I didn't know how that happened... but thanks for letting me know

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

採用された回答

Matt Fig
Matt Fig 2012 年 12 月 1 日
編集済み: Matt Fig 2012 年 12 月 1 日
% Say your given vector is:
X = [ 2 3 4 5 6 7 ];
% Now to make the matrix.
L = (1 + sqrt(1+4*length(X)))/2;
F = double(~eye(L));
F(~eye(L)) = X

その他の回答 (1 件)

Vic
Vic 2012 年 12 月 1 日
thanks!

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by