Unable to perform assignment because the size of the left side is 1-by-14 and the size of the right side is 14-by-14.

조회 수: 2 (최근 30일)
Unable to perform assignment because the size of the left side is 1-by-14 and the size of the right side is 14-by-14.
Error in SSA (line 87)
Tp=SalpPositions(i,:)>ub';Tm=SalpPositions(i,:)<lb';SalpPositions(i,:)=(SalpPositions(i,:).*(~(Tp+Tm)))+ub'.*Tp+lb'.*Tm;
Error in main_SSA (line 16)
[Best_score,Best_pos,SSA_cg_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
>>

채택된 답변

Walter Roberson
Walter Roberson 2021년 10월 6일
Your ub and lb need to be column vectors, not row vectors.
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 10월 6일
% Problem preparation
dim = 14;
ub = 1.1 * ones(dim, 1);
lb = 0.05 * ones(dim, 1);
fobj = @ofun;
%--------------------------------------------------------------------------
SearchAgents_no=20; %number of population
Max_iteration=1000; %number of iteration
%%
[Best_score,Best_pos,SSA_cg_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);

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

추가 답변 (2개)

Alan Weiss
Alan Weiss 2021년 10월 6일
The error statement is clear: your assignment (equality) statement has a 1-by-14 vector on the left and a 14-by-14 matrix on the right. Take a look at line 87 of your SSA function to see what is wrong. Are those the expected sizes of the variables?
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
tahseen alshmary
tahseen alshmary 2021년 10월 6일
편집: Walter Roberson 2021년 10월 6일
I do not know
my pararmeter is :
% Problem preparation
dim = 14;
ub = 1.1 * ones(1, dim);
lb = 0.05 * ones(1, dim);
fobj = @ofun;
%--------------------------------------------------------------------------
SearchAgents_no=20; %number of population
Max_iteration=1000; %number of iteration
%%
[Best_score,Best_pos,SSA_cg_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);

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


tahseen alshmary
tahseen alshmary 2021년 10월 6일

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for LEGO MINDSTORMS EV3 Hardware에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by