Error: Inner matrix dimensions must agree.

Hi, I am using "gamultiobj" to solve my problem. I, however, have no idea why the error message occurred
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> col_mop>@(x)x'*(B'*B)*x at 50
fun1 = @(x) x'*(B'*B)*x;
My objective function is coded as follows
fun1 = @(x) x'*(B'*B)*x;
fun2 = @(x) x'*x;
bifun = @(x) [fun1(x) fun2(x)];
The dimension of B'*B is m so x is an m-by-1 vector. The syntax for gamultiobj is
X = gamultiobj(FITNESSFCN,NVARS,A,b,Aeq,beq,LB,UB,options)
I have properly input the number of decision variables (NVARS) as m but the error message shows. I also check the dimensions using the command "whos" which showed what I wanted. Is there anything wrong?
Thanks in advance.

 채택된 답변

Paulo Silva
Paulo Silva 2011년 6월 15일

0 개 추천

댓글 수: 5

Chien-Chia Huang
Chien-Chia Huang 2011년 6월 15일
Thanks for the information. But I am a bit confused. The command ".*" should be element-wise product, right? For example, [2,3].*[1,4] = [2, 12]. What I am doing is vector-vector (vector-matrix) inner product, for instance, [2,3]'*[1,4] = 2 + 12 = 14. Have I gone wrong?
Paulo Silva
Paulo Silva 2011년 6월 15일
I have no clue what you want to do, just pointed you to a similar question, you are correct on those assumptions but you have this x'*(B'*B)*x , some part of those three multiplications doesn't work because of dimensions mismatch, see the size of every vector or array to find where the problem is.
Matt Fig
Matt Fig 2011년 6월 15일
@Chhien-Chia,
Show us the output of the following:
size(x) % I mean the argument to fun1 here...
size(B)
Chien-Chia Huang
Chien-Chia Huang 2011년 6월 15일
Thanks a lot, Paulo! I just found out what the problem is. The x in gamultiobj is by default supposed to be a row vector, but I thought intuitively of x as a column vector. The problem was just solved.
Chien-Chia Huang
Chien-Chia Huang 2011년 6월 16일
sorry Matt I did not see your reply. The output of size(B) was 5-by-10 and size(x) was 10-by-1. But the requested x in gamultiobj should be 1-by-10. Thanks, anyway. :D

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by