在Matlab中象征性地求解非线性最小化方程 [英] Solving nonlinear minimization equations symbolically in matlab
问题描述
我有一个不确定的大型方程组,对于任何给定的约束,我都针对该方程组搜索唯一的解决方案.我将问题简化为以下问题:
I have a large underdetermined equation system for which I search an unique solution in respect of any given constraints. I simplified my problem into the following one:
x²-4=0,
y²-9=0,
x*y=myMin,
x+y=myMin.
在Matlab中以符号方式实现此功能的最佳方法是什么,以便它返回
What is the best way to implement this in Matlab symbolically, so that it returns
x=2
y=-3
我正在搜索类似
syms x y
S=solve(...
x²-4==0,...
y²-9==0,...
x*y==myMin,...
x+y==myMin);
推荐答案
我不知道如何将min
作为功能命令指定给solve
.但这是一种解决方程式,然后根据您的约束对结果进行后处理的方法:
I do not know how specify the min
as a function command to solve
. But here's an approach that solves the equations and then post-processes the result according to your constraints:
syms x y
S=solve(x^2-4==0,y^2-9==0);
[~,idx] = min(double(S.x .* S.y)+double(S.x + S.y));
X = double(S.x(idx))
Y = double(S.y(idx))
这给出了:
X =
2
Y =
-3
必须使用double
命令转换符号结果,才能使用min
函数进行处理.
The symbolic results have to be converted using the double
command to allow processing with the min
function.
这篇关于在Matlab中象征性地求解非线性最小化方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!