how to copy rows and columns in a random matrix ?
1 回表示 (過去 30 日間)
古いコメントを表示
if i have matrix A
A = [ 1 0 1 1
0 0 1 0
0 1 0 1
1 1 0 1 ] ;
THEN i want to generate a random binary matrix S which the first and last row IN A appear in S matrix
AND the last column In A appear in S matrix ?
S = [ 1 0 1 1
0 1 0 0
1 0 1 1
1 1 0 1 ]
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2016 年 4 月 18 日
S=randi([0 1],size(A))
S([1 end],:)=A([1 end],:)
S(:,end)=A(:,end)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!