row dimension of aeq is inconsistent with length of beq.

5 visualizzazioni (ultimi 30 giorni)
Hello ,
I am trying to use the fmincon but am constantly getting the following error message.What do you suggest me to change? and one more question can we use more then one lower and upper bounds Thanks in advance.
X0=rand(3,1);
A = [];
B = [];
Beq=[0,0,0;0,0,0;0,0,0;0,0,23.2782000000000;0,26.4970000000000,26.4970000000000;0,26.5376000000000,0;24.0970000000000,25.9376000000000,0;24.6970000000000,24.7376000000000,0;25.2970000000000,24.1376000000000,24.1376000000000;29.1158000000000,26.5376000000000,26.5376000000000;0,24.4376000000000,24.4376000000000;0,25.3376000000000,0;0,25.0376000000000,0;0,26.1970000000000,0;0,26.5376000000000,26.5376000000000;0,25.8970000000000,25.8970000000000;0,0,0;0,26.2376000000000,0;0,25.0376000000000,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0];
Aeq=[6,11.4000000000000,11.4000000000000;9,13.3500000000000,13.3500000000000;8.10000000000000,11.4000000000000,11.4000000000000;6.60000000000000,13.5000000000000,13.5000000000000;6.90000000000000,10.2000000000000,10.2000000000000;8.70000000000000,13.5000000000000,13.5000000000000;7.80000000000000,12.9000000000000,12.9000000000000;8.40000000000000,11.7000000000000,11.7000000000000;9,11.1000000000000,11.1000000000000;6.30000000000000,13.5000000000000,13.5000000000000;0,11.4000000000000,11.4000000000000;0,12.3000000000000,12.3000000000000;0,12,12;0,9.90000000000000,9.90000000000000;0,13.5000000000000,13.5000000000000;0,9.60000000000000,9.60000000000000;0,13.2000000000000,13.2000000000000;0,13.2000000000000,13.2000000000000;0,12,12;0,13.2000000000000,13.2000000000000;0,0,12.9000000000000;0,0,12.6000000000000;0,0,12;0,0,13.5000000000000;0,0,12.3000000000000;0,0,11.1000000000000;0,0,12;0,0,11.7000000000000;0,0,12.3000000000000;0,0,9.30000000000000];
lb=[0,0,0];
ub=[20.8602,52.1504,75.61881];
[x, fval] = fmincon('ff', X0, A, B, Aeq, Beq, lb, ub)
here is the problem:
R_t=[0.06 0.06 0.06 0.06 0.06 0.11 0.11 0.3 0.3 0.3 0.3 0.3 0.11 0.11 0.06 0.06 0.06 0.06 0.06 0.06 0.11 0.11 0.11 0.11;
0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.09 0.09 0.09 0.09 0.09 0.09 0.27 0.27 0.27 0.27 0.27 0.27 0.09 0.09 0.09;
0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.04 0.07 0.07 0.07 0.22 0.22 0.22 0.22 0.22 0.22 0.07 0.07 0.07 0.07 0.04];
X=[x(1);x(2);x(3)];
f=R_t(1,:).*X(1,:)+R_t(2,:).*X(2,:)+R_t(3,:).*X(3,:);
  1 Commento
Image Analyst
Image Analyst il 23 Feb 2020
Edit your post. Highlight the code. Click the code icon on the toolbar. Click Submit to post your fixed post.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 24 Feb 2020
beq should be a vector that is the same length as the number of rows in Aeq. Your beq looks like an array the same size as Aeq.
  1 Commento
Walter Roberson
Walter Roberson il 24 Feb 2020
The idea is that Aeq*X==beq must be true. X is a vector so Aeq*X is a vector as well with the same number of rows as Aeq. A 2d array for beq cannot match.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by