i m using cuckoo search to optimise gabor filter parameters when code enters the loop mentioned herei get the Subscripted assignment dimension mismatch. Caused by: Subscripted assignment dimension mismatch error on line nests(r,c)=nests(r,c)+ste
1 view (last 30 days)
Show older comments
n=size(nests,1);
beta=3/2;
sigma=(gamma(1+beta)*sin(pi*beta/2)/(gamma((1+beta)/2)*beta*2^((beta-1)/2)))^(1/beta);
for r = 1:numb_of_nest % for each particle
for c = 1:4
u=randn(size(nests(r,c)))*sigma;
v=randn(size(nests(r,c)));
step=u./abs(v).^(1/beta);
nests(r,c)=nests(r,c)+stepsize.*randn(size(nests(r,c)));
% Apply simple bounds/limits
ns_tmp=nests(r,c);
I=ns_tmp<Lb(c);
ns_tmp(I)=Lb(I);
% Apply the upper bounds
J=ns_tmp>Ub(c);
ns_tmp(J)=Ub(J);
% Update this new move
nests(r,c)=ns_tmp;
end
end
0 Comments
Answers (1)
Walter Roberson
on 18 Mar 2014
You have
nests(r,c)=nests(r,c)+stepsize.*randn(size(nests(r,c)));
where r and c are scalars. so nests(r,c) can hold only a single value, and so the right hand side of the assignment must resolve to a single value. The nests(r,c) part of it is a single value. now look at randn(size(nests(r,c))); . Since nests(r,c) is a single value, its size() will be [1, 1], and randn([1 1]) is going to be a 1 x 1 random value, so that part is a single value. So now let's look at stepsize... and we see that it is not defined. Our best guess then becomes that stepsize is not a scalar value: if it is not then the multiplication will not give a scalar and you would have problems.
For one thing check in case stepsize is empty.
See Also
Categories
Find more on Logical 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!