how can I reach the unknown state by solving 2 inequalities in matlab?

조회 수: 2 (최근 30일)
azam ghamari
azam ghamari 2019년 4월 19일
댓글: Walter Roberson 2019년 4월 22일
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
Walter Roberson
Walter Roberson 2019년 4월 19일
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 ')'

댓글을 달려면 로그인하십시오.

답변 (2개)

azam ghamari
azam ghamari 2019년 4월 20일
yes, I solve that problem now but it gives me this:
ans =
Empty sym: 0-by-1
and what about the second part of my problem?
thanks

azam ghamari
azam ghamari 2019년 4월 22일
Actually I don't get result, and I wonder why nobody helps me/answer me on this question? I will be thankful if anybody can help me to reach the result.
thanks
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 22일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by