Index exceeds matrix dimensions.error for the line m(1:floor(n/2))=mod(x1(1:floor(n/2),y1));
조회 수: 1 (최근 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
댓글 수: 0
답변 (2개)
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...
댓글 수: 0
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
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!