필터 지우기
필터 지우기

How to solve an equation of the form A (matrix) x(vector) = b(vector) and a constant c where I have to find x and c, and x is only positive?

조회 수: 3 (최근 30일)
Hi, I have a matrix A
A =[1 1 2 2 0 0;
1 1 2 2 0 0;
0 0 0 1 0 0;
0 0 0 1 0 0;
3 0 0 0 0 0;
3 0 0 0 0 0;
3 0 0 0 1 0;
3 0 0 0 1 0;
3 0 0 0 1 0;
3 0 1 1 1 0;
3 0 1 1 1 0;
3 0 2 0 0 1;
3 0 2 0 0 1];
and a vector b
b = [64.20; 42.60; 14.60; 5.75; 30.40; 27.20; 36.50; 25.40; 40.60; 38.90; 15.50; 38.40; 35.30];
if I use linesolve, I have
x =
9.6000
57.7333
-17.1417
10.1750
5.3667
42.3333
but negative values are nor realistic, I was planning to use linear programming but I'm not sure if is the way to go since I also need to have a constant (which can be negative) so I can have
Axc=b
Can you recommend me something?
Thanks!

채택된 답변

Star Strider
Star Strider 2016년 12월 4일
If you want to avoid negative parameters, use the lsqnonneg function.
Example:
x = lsqnonneg(A,b)
x =
9.6
36.306
0
3.7469
1.0813
8.05

추가 답변 (1개)

KSSV
KSSV 2016년 12월 4일
Doc mldivide
  댓글 수: 4
German Preciat Gonzalez
German Preciat Gonzalez 2016년 12월 4일
that is why I want to use a constant C that multiplies vector x so the vector x can have only positive values: Axc=b
KSSV
KSSV 2016년 12월 4일
C = [1 1 -1 1 1 1 1]';
But you should do element by element .* multiplication.

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

카테고리

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