필터 지우기
필터 지우기

Mis match of dimensions

조회 수: 1 (최근 30일)
Moe
Moe 2014년 11월 3일
댓글: Star Strider 2014년 11월 3일
Suppose I want to find all maximum number in the matrix m:
I used this command line:
mm(:,:,j) = find( m(:,:,j) == maxlistm(:,:,j) );
If matrix m updated in each iteration, then next result for mm will be wrong. new mm dimension automatically will be match with the first mm (just repeat new maximum fined value).
Example: iteration 1:
m = [20;3;20;8;9;11;13;14;15;20];
then:
mm = [1;3;10]
now in iteration 2, m is:
m = [2;3;2;80;9;11;13;14;15;2];
then instead of given mm = [4], it will give me:
mm = [4;4;4] % 3 rows because in the first m, it found 3 max values

답변 (1개)

Star Strider
Star Strider 2014년 11월 3일
That result is most likely because you defined ‘mm’ as a 3-D matrix.
I would define it as a cell array instead. That will allow for varying numbers of returned values from your find call.
  댓글 수: 5
Star Strider
Star Strider 2014년 11월 3일
Getting the same error with that version:
Error using ones
Size inputs must be scalar.
Error in star (line 141415)
X2(:,:,j) = [a1(:,1), g2(:,:,j).*ones(size(a1),1)];
Star Strider
Star Strider 2014년 11월 3일
I don’t have any problems opening and reading it in xlsread or opening it in Excel.
The problem is with the size argument to ones. It is always a (1xN) vector (a scalar is (1x1)), where N is the number of dimensions of the argument. These lines will throw the same error:
q = rand(5,1);
r = ones(size(q),1);
I have no idea what you’re doing, so I can’t suggest a fix for it. If you want it to be size of ‘a1’, the correct syntax is:
ones(size(a1))

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

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by