systems of equations, with constraints

31 Ansichten (letzte 30 Tage)
Alina Abdikadyr
Alina Abdikadyr am 10 Apr. 2023
Kommentiert: Torsten am 17 Apr. 2023
Hello everyone! could you please help me with solving systems of equations in matlab.
In the given eqns, I have 4 unknowns and 3 eqns, which gives the infinite number of solutions. But in the code, it should choose the solution or solutions that will be constrained within the limits: y -> (+/-15); z -> (+/-20); k -> (+/-5), (k in degrees)
My systems of eqns:
-0.00293*x-0.0024*y+0.00015*z=0
0.0018*x+0.0005*y-0.00096*z=0
-0.0105*x+0.0021*y+1.4584*sin(k)=0
Thank you in advance!!!
  1 Kommentar
Torsten
Torsten am 10 Apr. 2023
x = y = z = k = 0.
If this does not work for you, please explain further.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

John D'Errico
John D'Errico am 10 Apr. 2023
Bearbeitet: John D'Errico am 10 Apr. 2023
This is a question more about understanding the mathematics of the problem, than of understanding how to solve it in MATLAB. Until you do the first, knowing how to solve it is impossible.
Your problem is a homogeneous nonlinear system. That means it has no constant term, and the all zeros solution solves the problem. Since the matrix is of full rank (if we set k==0) then the only solution when k==0 is x=y=z=0 too.
And since it is underdetermined (you have more variables than equations) then there will be infinitely many solutions.
Suppose k were known? As long as k is not of the form n*pi, then the problem would not be a homogeneous one. Now there wold be a unique solution, as a function of k.
syms x y z k real
assume(-15<= y <= 15)
assume(-20<= z <= 20)
E(1) = -0.00293*x-0.0024*y+0.00015*z==0;
E(2) = 0.0018*x+0.0005*y-0.00096*z==0;
E(3) = -0.0105*x+0.0021*y+1.4584*sin(k)==0;
xyz_k = solve(E,[x,y,z],'returnconditions',true)
xyz_k = struct with fields:
x: (54179560*sin(k))/479073 y: -(61806992*sin(k))/479073 z: (208186600*sin(k))/1437219 parameters: [1×0 sym] conditions: -7186095/61806992 <= sin(k) & sin(k) <= 7186095/61806992
So, we have a solution for ANY value of k that satisfies the requirements on y and z. But there is a condition on k. I've left k in radians. We can convert that to degrees later. The requirement is that
abs(sin(k)) < 7186095/61806992
(Again, there k is in radians) And what does that mean, in degrees? I'll use asind here, so we can have an answer in degrees for the necessary bounds on k.
asind(7186095/61806992)
ans = 6.6767
It tells us there will be a solution for ANY value of k, such that -6.6767<=k<=6.6767 degrees. And since you tell us that k must be in the interval [-5,5] degrees, then we have the complete solution locus.
x = xyz_k.x
x = 
y = xyz_k.y
y = 
z = xyz_k.z
z = 
Again, if k is in degrees, then you will use sind there, not sin. I would strongly suggest you begin learn to work in radians though.
  6 Kommentare
Alina Abdikadyr
Alina Abdikadyr am 17 Apr. 2023
thank you! also, my coefficient of k is changed, my new system of equations looks like:
E(1) = -0.00293*x-0.0024*y+0.00015*z==0;
E(2) = 0.0018*x+0.0005*y-0.00096*z==0;
E(3) = -0.0105*x+0.0021*y+0.103239*sin(k)==0;
so xyz_k gives me different information, so how could I find the new limits?
x: (2878797596617218753125*sin(k))/359592164047210938368
y: -(1642038252283145770625*sin(k))/179796082023605469184
z: (11061866942587024953125*sin(k))/1078776492141632815104
parameters: [1×0 sym]
conditions: symtrue
Torsten
Torsten am 17 Apr. 2023
so how could I find the new limits?
Which limits ?
You have limits on k and want to find the resulting limits for x, y and z ?
You have limits on x, y and z and want to find the resulting limits on k ?
Please state your problem properly.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jon
Jon am 10 Apr. 2023
If you have the optimization toolbox, you could use lsqnonlin, where your f(x) is the system of equations you show above, and your lower and upper bounds are the bounds you describe on y, z and k.
As you note, there will, in general be an infinite number of solutions. This may even be the case with your bounds. If so, the best you can do is obtain individual solutions that satisfy the equations, but obviously not all of them, unless you have a lot of time :)
  4 Kommentare
Jon
Jon am 10 Apr. 2023
I assumed that k was also an "unknown". Following your suggestion, I guess you could pick arbitrary values of k within the allowable range -5<= k <= 5 and then solve for x,y and z as a linear program.
Torsten
Torsten am 10 Apr. 2023
Bearbeitet: Torsten am 10 Apr. 2023
No. I would solve for x,y,z and w = sin(k) and then deduce k as k = asin(w).

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by