Can symbolic tool box transfer max(f(x), y) into symbolic variable?
1 回表示 (過去 30 日間)
古いコメントを表示
I was using fmincon for nonlinear optimization, but When I tried to use MATLAB symbolic toolbox to provide joccobian of my constraint function, MATLAB showed terminated saying the symbolic toolbox cannot transfer function max(f(x), 0). In my constraint function, I called a function handle, and in that function there is max(f(x), 0). I used max(f(x), 0) in order to increase the robustness of my code, otherwise there is a high chance that MATLAB will terminate due to the complex number generated by my constraint function, which is wrong. I have no idea how to deal with the problem between symbolic toolbox and max(f(x),0), if anyone of you have solution I would be very grateful.
0 件のコメント
回答 (1 件)
Walter Roberson
2015 年 5 月 26 日
I suggest experimenting with a piecewise(), which you can generate inside the symbolic engine by using
min0 = evalin(symengine, 'x -> piecewise(x<0, 0, x)');
then min0(f(x)).
If that doesn't work, then Heaviside it:
syms min0(x)
min0(x) = x*Heaviside(x);
then min0(f(x))
2 件のコメント
Walter Roberson
2015 年 5 月 26 日
I already answered that in your earlier question http://uk.mathworks.com/matlabcentral/answers/218576-how-to-pass-extra-parameter-as-a-symbolic-variable-to-objective-and-constraint-functions
参考
カテゴリ
Help Center および File Exchange で Equation Solving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!