How to generate matrix using MATLAB ?
13 ビュー (過去 30 日間)
古いコメントを表示
How to generate matrix of 24 * 96 order using MATLAB as shown in figure.

3 件のコメント
採用された回答
Shashank Prasanna
2014 年 2 月 14 日
There isn't a right answer. Here is one:
X = eye(4);
X(:,repmat(1:4,4,1))
Change 4 to something else if you want to wider or taller.
0 件のコメント
その他の回答 (3 件)
Wayne King
2014 年 2 月 14 日
編集済み: Wayne King
2014 年 2 月 14 日
I'm sure there are many different ways:
X = zeros(1,96);
X(1:4) = 1;
K = 0;
for nn = 1:24
Y(nn,:) = circshift(X,K,2);
K = K+4;
end
Assuming that each row of 96 elements has 4 1's and each row is a shifted version of the previous one.
Roger Stafford
2014 年 2 月 14 日
Here's another way:
m = 4; n = 24;
x = reshape(diff(floor((m*n+m*(0:m*n^2))/(m*n+1))),n,m*n);
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!