필터 지우기
필터 지우기

Matlab Warning: Concatenation of empty arrays

조회 수: 6 (최근 30일)
Andrea
Andrea 2013년 1월 26일
Hi,
I have write these lines in a matlab function
[r2, c2] = find(row == -2);
[r10, c10] = find(row == -10);
[r11, c11] = find(row == -11);
[r15, c15] = find(row == -15);
c = [c2 c10 c11 c15];
When I run the function on the matlab prompt I visualize this warning on the last line of the above code
Warning: Concatenation involves an empty array with an incorrect number of rows.
How can I resolve this warning?
Thanks in advance
Andrew
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 1월 26일
Please tell us what you get for
size(c2)
size(c10)
size(c11)
size(c15)

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

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 1월 26일
편집: Azzi Abdelmalek 2013년 1월 26일
Because c2 and c10, for example, have not the same size, then you can't concatenate them horizontally. Use instead
c = [c2 ;c10; c11; c15];

Walter Roberson
Walter Roberson 2013년 1월 26일
Perhaps this would be suitable?
c = find(row == -2 | row == -10 | row == -11 | row = -15);
which could also be coded as
c = find(ismember(row, [-2, -10, -11, -15]));
  댓글 수: 1
Andrea
Andrea 2013년 1월 28일
row is a row vector can be contains or a single value between {-2,-10,-11,-15} or a combination of its.
I should select the max column of the values contained in row and in fact in my code I have this:
c = [c2 c10 c11 c15]; c = max(c);
I obtain the same behaviour with this instruction, for example:
c = max(find(ismember(row, [-2, -10, -11, -15])));
Thanks
Andrew

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

카테고리

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