필터 지우기
필터 지우기

Why does the [x,fval,ex​itflag,out​put,lambda​] = linprog(f,​A,b,Aeq,be​q,lb,ub) function return only integer numbers?

조회 수: 2 (최근 30일)
Hi, I'm doing an optimization problem where I use the [x,fval,exitflag,output,lambda] = linprog(f,A,b,Aeq,beq,lb,ub) funtion. However, the results I get give me only integer numbers. For example, I'm expecting a result like 1.710, but I get 2.0. When I expect a value of 0.855, I get 1.0
How can I get the rational numbers with decimals, instead of only integer numbers?
  댓글 수: 8
Romeo Tahal
Romeo Tahal 2022년 10월 28일
The results are slightly higher than expected, but I can live with that.
Torsten
Torsten 2022년 10월 28일
If you know a solution you can live with, you don't need an optimizer, do you ?

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

답변 (1개)

Sarthak
Sarthak 2023년 9월 11일
Hi Romeo,
I understand that you want to set the precision of the output variable.
You can use the format function to set the precision of the output.
format long
x,fval,exitflag,output,lambda = linprog(f,A,b,Aeq,beq,lb,ub);
To know more information about the format function, you can visit the documentation page of format.
I hope this solves your query.

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by