Creating matrix as per given format

조회 수: 1 (최근 30일)
Arundhatee Talukdar
Arundhatee Talukdar 2011년 11월 10일
I want to have a matrix like
a=[ 1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3]
the difference is that in my case the range is till 200 in place of 3. How do I do it? Please help me!

답변 (2개)

Walter Roberson
Walter Roberson 2011년 11월 10일
See kron(), ndgrid(), and repmat() for tools to make such a matrix.
  댓글 수: 2
Arundhatee Talukdar
Arundhatee Talukdar 2011년 11월 10일
I am very new to Matlab, and this answer is not at all helping me.
Walter Roberson
Walter Roberson 2011년 11월 11일
http://www.mathworks.com/help/techdoc/ref/kron.html
http://www.mathworks.com/help/techdoc/ref/ndgrid.html
http://www.mathworks.com/help/techdoc/ref/repmat.html
As you are a beginner, you might perhaps also want these:
http://www.mathworks.com/help/techdoc/ref/horzcat.html
http://www.mathworks.com/help/techdoc/ref/vertcat.html

댓글을 달려면 로그인하십시오.


Fangjun Jiang
Fangjun Jiang 2011년 11월 11일
N=200;
M=N^2;
a=zeros(M,2);
count=0;
for k=1:N
for j=1:N
count=count+1;
a(count,1:2)=[k j];
end
end

카테고리

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