非线性不平等系统

11视图(洛杉矶st 30 days)
Martin Androvich
Martin Androvich 2021年8月21日
Commented: Martin Androvich2021年8月22日
我有一个我希望解决这两个变量的四个不平等(约束)的非线性系统 S G , as follows:
I can solve this using WolframAlpha as shown here , but am curious how to solve this problem using MATLAB? Either a symbolic solution (like Wolfram provides) or a set of possible integer solutions (or something alike).

Accepted Answer

John D'Errico
John D'Errico 2021年8月21日
Start with, what can we do in symbolic form?
symsS G Real
Eq(1) = G > 21;
Eq(2) = S >= 15;
Eq(3) = S <= 18;
Eq(4) = 61 <= 2*S + G;
eq(5)= 2*s + g <= 63;
eq(6)= atand(s/g)> = 30;
Eq(7) = atand(S/G) <= 45;
解决(eq,s,g,'returnconditions',真正的)
警告:无法找到明确的解决方案。对于选项,请参阅帮助.
ans =struct with fields:
S: [0×1 sym] G: [0×1 sym] parameters: [1×0 sym] conditions: [0×1 sym]
There are infinitely many real solutions. So solve cannot handle the problem.
Those inequalities are all just linear though, linear in S and G. Even the case of the atan is linear, sicne over a limited region, the tangent function is monotonic. So we know that if
atand(S/G) <= 45
然后,通过双方的切线,我们不会改变不平等的迹象。告诉我们:
s/g <= 1
或者
S <= G
Likewise, we can infer that
S/G >= sqrt(3/3)
So we have
S >= sqrt(3)/3*G
There is a nice utility called plotregion, that lives on the file exchange for free download. If we represent this linear sytem of inequalities by the matrix A and vector b, where A*x >= b, we might do:
lb = [15 21];% lower bounds on S and G respectively
ub = [18 inf];% upper bounds on S and G
A = [2 1;-2 -1;-1 1;1 -sqrt(3)/3];% linear inequalities
b = [61;-63;0;0];
情节区域(a,b,lb,ub)
XLABEL'S'
ylabel'G'
网格
That region in the (S,G) plane is where your solutions live. There are infinintely many pairs of real solutions. It looks like Alpha was willing to generate some of them.
If you wish to show the integer solutions, a simple graphical way to do so is to overlay an integer lattice on top of that domain.
[s,g] = meshgrid(16:18,25:30);
hold
情节(s,g,'ro')
Where you should see the six pairs of integer solutions that live in the solution locus. Five of them lie on the boundary, one is interior.
1 Comment
Martin Androvich
Martin Androvich 2021年8月22日
That's a very detailed explanation - thank you a lot!

Sign in to comment.

More Answers (1)

艾伦·史蒂文斯
艾伦·史蒂文斯 2021年8月21日
首先绘制一些绑定不平等的行
%g> 21
%15 <= s <= 18
% 61<=2S+G<=63
%30 <= atan(s/g)<= 45-> sqrt(3)/3 <= s/g <= 1-> g <= sqrt(3)s and g> = s
% Define functions
G1 = @(S) 61 - 2*S;% G >= G1
g2 = @(s)63-2*s;% G <= G2
G3 = @(S) sqrt(3)*S;% G <= G3
S = [15 18];
plot(S,G1(S),S,G2(S),S,G3(S)),grid
s1 = 61/(2+sqrt(3)); s2 = 63/(2+sqrt(3));
g1 = G1(s1); g2 = G2(s2);
补丁([S1,18,18,S2],[G1,25,27,G2],'y')
Xlabel('S'), ylabel('G')
% then find the intersection points.
%解决方案在万博 尤文图斯黄色斑块区域。

s manbetx 845


释放

R2021a

Community Treasure Hunt

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

开始狩猎!