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)
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

Answers (1)

Walter Roberson
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.
  1 Comment
amir
amir on 18 Mar 2014
Thanx for the reply stepsize=0.01*step.*(nests(r,c)-best); step size is calculated as stated above in the code which i think is also a saclar value Any clue thanks in advance

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!