필터 지우기
필터 지우기

Grouping set of numbers with different size of rows

조회 수: 1 (최근 30일)
czeslaw
czeslaw 2017년 12월 8일
편집: per isakson 2017년 12월 8일
Hi all,
I would like to group set of numbers into a container that I can use later in for loops: The first column are the set numbers. Example:
groupNum=[
1 61 32 624 15 2000;
2 25 3 635;
3 19 20 49 30;
4 56 28;
5 29 51 60;
]
for i=1: size(groupNum,1) % for 1 to 5 in this case
for i=1: size(groupNum,2) % for 1 to number of column in the set
%do something
end
end
That code will result in error because the size of the matrix is not consistent. Any advice would be much appreciated.
Thanks in advance.
  댓글 수: 2
czeslaw
czeslaw 2017년 12월 8일
Thanks for reply. I tried that before posting this and its not working: e.g.
aaa={1 2 3;1 2}
will give error: Dimensions of matrices being concatenated are not consistent.
per isakson
per isakson 2017년 12월 8일
편집: per isakson 2017년 12월 8일
Good night! See @Jan's answer.

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

답변 (1개)

Jan
Jan 2017년 12월 8일
Maybe:
groupNum = {1, [61 32 624 15 2000]; ...
2, [25 3 635]; ...
3, [19 20 49 30]; ...
4, [56 28]; ...
5, [29 51 60]}

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by