How to get a random possible solution from 'solve' function when getting unknown parameters z1 and conditions
Mostrar comentarios más antiguos
Here are my codes:
syms x y z;
eq1 = x*x + y*y + z*z == 0.14;
eq2 = x*y + y*z + z*x == 0.11;
equations = [eq1, eq2];
assume(x>=0);
assumeAlso(y>=0);
assumeAlso(z>=0);
assumeAlso(x<=1);
assumeAlso(y<=1);
assumeAlso(z<=1);
S=solve(equations,[x,y,z],'ReturnConditions',true);
disp(S)
S will print:
x: [4×1 sym]
y: [4×1 sym]
z: [4×1 sym]
parameters: z1
conditions: [4×1 sym]
and S.x is like:
(- 75*z1^2 - 30*z1 - 2)^(1/2)/10 - z1/2 - 3/10
- z1/2 - (- 75*z1^2 - 30*z1 - 2)^(1/2)/10 - 3/10
(- 75*z1^2 + 30*z1 - 2)^(1/2)/10 - z1/2 + 3/10
3/10 - (- 75*z1^2 + 30*z1 - 2)^(1/2)/10 - z1/2
and S.conditions is like:
5*z1 + 3 <= (- 75*z1^2 - 30*z1 - 2)^(1/2) & -13 <= 5*z1 + (- 75*z1^2 - 30*z1 - 2)^(1/2) & (- 75*z1^2 - 30*z1 - 2)^(1/2) <= 5*z1 + 13 & z1/2 + 3/10 <= -(- 75*z1^2 - 30*z1 - 2)^(1/2)/10 & 0 <= z1 & z1 <= 1
5*z1 + 3 <= (- 75*z1^2 - 30*z1 - 2)^(1/2) & -13 <= 5*z1 + (- 75*z1^2 - 30*z1 - 2)^(1/2) & (- 75*z1^2 - 30*z1 - 2)^(1/2) <= 5*z1 + 13 & z1/2 + 3/10 <= -(- 75*z1^2 - 30*z1 - 2)^(1/2)/10 & 0 <= z1 & z1 <= 1
5*z1 <= (- 75*z1^2 + 30*z1 - 2)^(1/2) + 3 & -7 <= 5*z1 + (- 75*z1^2 + 30*z1 - 2)^(1/2) & (- 75*z1^2 + 30*z1 - 2)^(1/2) <= 5*z1 + 7 & z1/2 <= 3/10 - (- 75*z1^2 + 30*z1 - 2)^(1/2)/10 & 0 <= z1 & z1 <= 1
5*z1 <= (- 75*z1^2 + 30*z1 - 2)^(1/2) + 3 & -7 <= 5*z1 + (- 75*z1^2 + 30*z1 - 2)^(1/2) & (- 75*z1^2 + 30*z1 - 2)^(1/2) <= 5*z1 + 7 & z1/2 <= 3/10 - (- 75*z1^2 + 30*z1 - 2)^(1/2)/10 & 0 <= z1 & z1 <= 1
How can i get any possible solution from parameter z1 and its conditions?
For instance, one of the possible solution would be x=0.1 y=0.2 z=0.3
But I have no idea how to get a random solution.
I'm sorry that my English is poor.
Thanks for your helping!!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
