Index exceeds matrix dimensions.error for the line m(1:floor(n/2))=mod(x1(1:floor(n/2),y1));
1 view (last 30 days)
Show older comments
%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 Comments
Answers (2)
Walter Roberson
on 11 Mar 2016
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 Comments
Zakaria Al-Soud
on 6 Jan 2020
Please help for the error message below:
Error using hinf (line 144)
ERROR: Must have dim(y1) >= dim(u2)
2 Comments
Walter Roberson
on 6 Jan 2020
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.
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!