필터 지우기
필터 지우기

Where I am mistaking?

조회 수: 2 (최근 30일)
Bogdan
Bogdan 2014년 3월 8일
댓글: Bogdan 2014년 3월 10일
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?

채택된 답변

Alan Weiss
Alan Weiss 2014년 3월 10일
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
Bogdan
Bogdan 2014년 3월 10일
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.

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

추가 답변 (1개)

Dishant Arora
Dishant Arora 2014년 3월 8일
Read the manual properly.
doc linprog
You are missing some input argument while calling.
  댓글 수: 3
Dishant Arora
Dishant Arora 2014년 3월 8일
you getting some error??
Bogdan
Bogdan 2014년 3월 10일
Same error, yes :)

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

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by