Seeking help creating a double matrix of ones and minus ones
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I'm relatively new to matlab and I'm trying to create a matrix like the example below. But I can't seem to get the code correct. I've tried the following code neither of which are correct. Would somebody be able to help me out?
Much appreciated
N=5;
ot = ones(N,1);
A = spdiags([-ot -ot],[0 N],N,N*2);
and
A = sparse(tril(ones(N)));
1 -1
11 -1-1
111 -1-1-1
1111 -1-1-1-1
11111-1-1-1-1-1
0 件のコメント
採用された回答
Iain
2013 年 8 月 21 日
startpoint = eye(desired_size);
positives = cumsum(startpoint)
whole_thing = [positives -positives]
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!