# Using linprog for equation with exponential and upper limit

3 ビュー (過去 30 日間)
Orongo 2018 年 2 月 15 日
コメント済み: Walter Roberson 2018 年 2 月 16 日
Hi, I am replicating a calculation done in Excel that set up the equation mu(x) accordingly Excel uses Solver nonlinear GRG, and I'm thinking of using Matlab's function linprog to replicate this. The unknown parameters are a, b and c, where x represent the age. I understand the from the web that x=linprog(f,A,b) and struggle to understand what f and A should be in my program. I follow the first vector of elements in A should be ones, but that is as far as I get. Please advise.
Many thanks.

サインインしてコメントする。

### 採用された回答

Birdman 2018 年 2 月 15 日
These looks like a piecewise function and can easily be replicated by MATLAB's piecewise function(requires Symbolic Toolbox):
syms a b c x
mu(x)=piecewise(x<=100,a+b*exp(c*x),x>100,a+b*exp(c*100)+(x-100)*0.01)
##### 1 件のコメント表示非表示 なし
Walter Roberson 2018 年 2 月 16 日
This will not work with linprog(). linprog() accepts a vector of coefficients, not a function.

サインインしてコメントする。

### その他の回答 (1 件)

Walter Roberson 2018 年 2 月 15 日
Your function is nonlinear in c and x. You cannot use linprog for this. linprog is strictly for linear functions.
If you did not have the a + portion of the expression then you could potentially have used a log transform, log(b) + c*log(x) which is linear in log(x)... But that will not work with the a+ portion of the expression being there.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!