# why am I getting this linprog error ?

조회 수: 19 (최근 30일)
Aidy 2013년 11월 8일
답변: Jonathan LeSage 2013년 11월 8일
Hi ,
I get the following error using linprog :
The number of columns in Aeq must be the same as the length of f.
anyway to overcome it?

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

### 답변 (1개)

Jonathan LeSage 2013년 11월 8일
You should check the dimensions of both your 'f' vector and your 'Aeq' matrix. Both of these values are multiplied with the vector to optimize, 'x', and accordingly, the dimensions must allow proper matrix multiplication.
First, check the length of 'f'
length(f)
As you know, the length of 'f' dictates the number of variables to optimize in vector 'x'. As a result, we need to make sure that the dimensions of 'Aeq' make sense too:
[m,n] = size(Aeq)
The value of 'm' gives use the number of rows in 'Aeq' which tells us how many equality constraint equations that we are enforcing on this linear program. Conversely, 'n' tells use the number of columns in 'Aeq' which indicates the size of 'x'. As a result, the number of columns of 'Aeq' and the length of 'f' must be equivalent (which is the error message that you're receiving).
Two potential corrections:
• If 'm' equals the length of 'f', you may have transposed your 'Aeq' matrix. You could fix this by transposing your Aeq matrix (Aeq = Aeq').
• Your equations might not be consistent, and you should write them out to ensure your equations make sense.
Hope this helps!

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

### 카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by