Azzera filtri
Azzera filtri

Where I am mistaking?

2 visualizzazioni (ultimi 30 giorni)
Bogdan
Bogdan il 8 Mar 2014
Commentato: Bogdan il 10 Mar 2014
Hello;
I am trying to make a simple linear programming optimization. I came up with this code:
clear;
y=1663;
f=[100; 100; 100; 100; 100; 100; 100; 100];
A=[1/867.2 1/704.7 1/619.2 1/679 1/770.3 1/658.5 1/749 1/783.1
-105.2 -74.4 -94.3 -88.2 -108.9 999 -112.7 -91.4
-94.1 -71.2 -87.6 -87.8 -99.4 999 -100 -81.2
0.5 0.6 4.5 3 28 15 4.5 12.5
0.78 2.11 0.01 0.01 0.56 0.09 0.02 0.9
93.63 16.3 0.01 0.01 1.44 0.09 0.03 37.64
0.82 3.23 0.03 0.36 3.13 29.97 0.04 16.16];
b=[y/0.775; -95*y; -85*y; 10*y; 1*y; 35*y; 18*y];
Aeq=[1; 1; 1; 1; 1; 1; 1; 1];
beq=y;
lb=zeros(8,1);
hb=[550; 250; 50; 200; 50; 350; 400, 700];
linprog(f, A, b, Aeq, beq, lb, hb);
When I try to run it, it says that The number of rows in A must be the same as the number of elements of b.
A has 7 rows and b has 7 elements, as it can be seen. I cannot see the mistake. Where is it?

Risposta accettata

Alan Weiss
Alan Weiss il 10 Mar 2014
I believe that your Aeq matrix should be a row vector, not a column vector.
Is your A matrix a vector or a matrix? I mean, don't you need some semicolons to separate the rows?
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Commento
Bogdan
Bogdan il 10 Mar 2014
Yes, that was the problem. Aeq should have been a row vector. I gotta love Matlab: it shows the error in a line, but the error is in another line :))
A is a matrix and this time I don't need semicolons, because Matlab interprets it as a matrix in the form that is written. In this case, semicolons are not needed.
Thank you for your help.

Accedi per commentare.

Più risposte (1)

Dishant Arora
Dishant Arora il 8 Mar 2014
Read the manual properly.
doc linprog
You are missing some input argument while calling.
  3 Commenti
Dishant Arora
Dishant Arora il 8 Mar 2014
you getting some error??
Bogdan
Bogdan il 10 Mar 2014
Same error, yes :)

Accedi per commentare.

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by