필터 지우기
필터 지우기

Index exceeds array bounds.

조회 수: 1 (최근 30일)
Bushra Mumtaz
Bushra Mumtaz 2019년 5월 3일
댓글: Roy Kadesh 2019년 5월 3일
Kindly help ... i m new in matlab ..can't understand the error
Error in clone_mut_selection (line 12)
g = (randn./beta) .* exp(-fitin(i));
function [C] = clone_mut_selection(Ab,Nc,beta,fitin,xmin,xmax,ymin,ymax,f)
% C -> matrix of clones
% g -> vector with Gaussian mutation
% Ab -> matrix of antibodies
% N -> cardinality of Ab
% Nc -> number of clones for each candidate
[N,L] = size(Ab);
C = [];
for i=1:N
vones = ones(N,1);
Cc = vones * Ab(i,:);
% g = (randn(Nc,L)./beta) .* exp(-beta.*fitin(i));
g = (randn(N,L)./beta) .* exp(-fitin(i));
g(1,:) = zeros(1,L); % Keep one previous individual for each clone unmutated
c = Cc + g;
% Keeps all elements of the population within the allowed bounds
Ixmin = find(c(:,1) < xmin); Ixmax = find(c(:,1) > xmax);
%Iymin = find(c(:,2) < ymin); Iymax = find(c(:,2) > ymax);
if ~isempty(Ixmin)
c(Ixmin,1) = Cc(length(Ixmin),1);
end
if ~isempty(Ixmax)
c(Ixmax,1) = Cc(length(Ixmax),1);
end
% if ~isempty(Iymin)
% c(Iymin,2) = Cc(length(Iymin),2);
% end
% if ~isempty(Iymax)
% c(Iymax,2) = Cc(length(Iymax),2);
% end
x = c(:,1); y = c(:,2);
% fit = eval(f);
fit = (fitnessfunction(Ab,N));
[out,I] = max(fit);
C = [C;c(I,:)]; % C contains only the best individuals of each clone
end
  댓글 수: 3
Rik
Rik 2019년 5월 3일
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.
Bushra Mumtaz
Bushra Mumtaz 2019년 5월 3일
편집: Bushra Mumtaz 2019년 5월 3일
Thanks Rik
and full error is Index exceeds array bounds.
Error in clone_mut_selection (line 14)
g = (randn(N,L)./beta) .* exp(-fitin(i));

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

답변 (1개)

Roy Kadesh
Roy Kadesh 2019년 5월 3일
Then your loop variable is bigger than fitin. You should make sure that this is not the case.
function [C] = clone_mut_selection(Ab,Nc,beta,fitin,xmin,xmax,ymin,ymax,f)
% C -> matrix of clones
% g -> vector with Gaussian mutation
% Ab -> matrix of antibodies
% N -> cardinality of Ab
% Nc -> number of clones for each candidate
[N,L] = size(Ab);
C = [];
if N>numel(fitin)
error('fitin is not big enough')
end
for i=1:N
  댓글 수: 4
Bushra Mumtaz
Bushra Mumtaz 2019년 5월 3일
I m doing feature selection using ainet n then fiding accuracy with SVM classifier...Can I have your email id so that I sent you my complete code may b then I get some help
Roy Kadesh
Roy Kadesh 2019년 5월 3일
You should be able to attach your m-files to the question or to a comment. I don't have any experience with machine learning, so I don't know if I can help you. Your entire function doesn't really make sense to me, because you didn't document all inputs. I don't know the norma function, and why you overwrote the function fit with a variable. You also forgot the ymin and ymax inputs and f (which is stored in ymin) is unused.

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by