How to generate matrix using MATLAB ?

3 次查看(过去 30 天)
How to generate matrix of 24 * 96 order using MATLAB as shown in figure.
  3 个评论
Explorer
Explorer 2014-2-15
编辑:Explorer 2014-2-15
Yeah, I wanted to create matrix like one shown above in MATLAB not in Excel.
Jos (10584)
Jos (10584) 2014-2-15
take care … your MS product activation failed … ;-)

请先登录,再进行评论。

采纳的回答

Shashank Prasanna
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.

更多回答(3 个)

Wayne King
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
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);

Jos (10584)
Jos (10584) 2014-2-15
An easy way:
m = kron(eye(24),ones(1,4))

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by