how can I reach the unknown state by solving 2 inequalities in matlab?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi guys. I have two questions:
firstly : I wanna solve and inequal in matlab and I write below code:
clear all;
clc;
close all;
syms x1 x2 x3 x4
cond1=x1>36;
cond2=x2>8.5;
cond3=x3>0.05;
cond4=x4>2.2;
cond5=(x1*(-0.38*x1+0.04*x2-2.4*x3-0.028*x4))+(x2*(0.1*x1-0.01*x2+x3+0.011*x4)+(x3*(-0.06*x1+0.007*x2-0.742*x3-0.0065*x4)+x4*(-0.029*x1-0.028*x2-0.255*x3-0.086*x4)<=-10*(.5)*(x1.^2+x2.^2+x3.^2+x4.^2);
conds=[cond1 cond2 cond3 cond4 cond5];
sol=solve(conds,[x y],'ReturnConditions',true);
sol.x1
sol.x2
sol.x3
sol.x4
sol.x5
sol.parameters
sol.conditions
but it gives me this error:
Error: File: inequation.m Line: 14 Column: 193
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
And my another questions is that assume that I want to solve 2 inequalities with a common unknown states besides other conds and I reach to the result of unknown state. For example in above problem, assum that this problem is the first problem in inequality in the right of it, instead of -10 I put an unknow state (K), and the second problem is like the first problem but I the limit for each of x1,x2,x3,x4 is as below
x1>30; x2>8;
x3>-9;
x4>4.5;
cond5=(x1*(-0.6988*x1+0.0518*x2-0.57*x3+0.0026*x4)+(x2*(0.32*x1-0.029*x2-0.4459*x3-0.0005*x4)+x3*(-0.2754*x1+0.0248*x2-0.3921*x3+0.0004*x4)+(x4*(0.003*x1-0.0012*x2+0.0003*x3-0.0833*x4))<=-K*(.5*x1.^2+x2.^2+x3.^2+x4.^2)
now how can I solve it and reach K?
1 Kommentar
Walter Roberson
am 19 Apr. 2019
You are missing two ) in defining cond5 .
Count brackets as you go. Start with 0. Every time you encounter a '(', increase your count by 1. Every time you encounter a ')', decrease your count by 1. At the end of the line you will find that you are at count 2, indicating you had two '(' that have no matching ')'
Antworten (2)
azam ghamari
am 22 Apr. 2019
1 Kommentar
Walter Roberson
am 22 Apr. 2019
None of us know what the proper place of the two missing ) is.
MATLAB struggles with inequalities.
Also, most of the time when it does find a solution, it just displays a nominal solution -- a point that satisfies the conditions, rather than representing the collection of points that satisfy the conditions. I have posted in the past as to how it chooses the representative point when it internally knows the boundaries.
Siehe auch
Kategorien
Mehr zu Function Creation finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!