How to generate matrix using MATLAB ?

조회 수: 2 (최근 30일)
Explorer
Explorer 2014년 2월 14일
댓글: Explorer 2014년 2월 15일
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