필터 지우기
필터 지우기

Index exceeds matrix dimensions.error for the line m(1:floor(​n/2))=mod(​x1(1:floor​(n/2),y1))​;

조회 수: 2 (최근 30일)
%finger print template generation
d=bwdist(v);
so=sort(d);
ud=unique(so);
UD=uint8(ud);
uni=unique(UD);
n=size(uni);
u1=uni(1:floor(n/2));
u2=uni(n/2+1:floor(n));
for s=1:floor(n/2);
x1(1:floor(n/2))=u1(1:floor(n/2));
y1=u1(end);
m(1:floor(n/2))=mod(x1(1:floor(n/2),y1));
sud2(1:floor(n/2))=m(1:floor(n/2));
end

답변 (2개)

Walter Roberson
Walter Roberson 2016년 3월 11일
You have mod(x1(1:floor(n/2),y1)) which uses two dimensions to x1 and which does not have a second parameter for the mod() call. You probably want mod(x1(1:floor(n/2)),y1)
By the way, I recommend that you assign floor(n/2) to a variable, as you use it often.
You are using
n=size(uni);
which is assuming that size() returns a scalar. size() always returns a vector with at least two components. Your uni will be a vector, so you should be using length() instead of size()
Your line
u2=uni(n/2+1:floor(n));
is assuming that n/2+1 is an integer, which in turn requires that n/2 is an integer which requires that n is even. There is no reason for you to expect an even number of unique values. Now if you had assigned floor(n/2) to a variable then you could have added one to that variable...

Zakaria Al-Soud
Zakaria Al-Soud 2020년 1월 6일
Please help for the error message below:
Error using hinf (line 144)
ERROR: Must have dim(y1) >= dim(u2)
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 1월 6일
In the context of that code, there is a D12 matrix, and the number of rows for that matrix must be greater than or equal to the number of columns of the matrix.
The code supports more than one calling format. In one of the formats, the first parameter is a system that has been constructed with mksys(); the D12 matrix is the 7th parameter to mksys(). In the other major calling sequence, the parameters that would be passed to mksys can instead be passed directly to hinf, and in that case the D12 matrix is the 7th parameter to hinf().
It looks to me as if hinf() would seldom be called by the user, and would instead be called by other routines such as the hinf synthesis routine, so it might be necessary to use the debugger to chase back to find out why that parameter is coming out with fewer rows than columns.
Walter Roberson
Walter Roberson 2020년 1월 7일
I just filed a bug report about the error message being confusing.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by