How can I add conditions to a system of equations?

15 visualizaciones (últimos 30 días)
Domenico Mancini
Domenico Mancini el 22 de Nov. de 2021
Respondida: Star Strider el 22 de Nov. de 2021
regarding this code, i want to add the conditions that the variables takes values between 1 and 9, so 1<q,w,e,r,t,y,u,i,o>9. thank you
syms q w e r t y u i o
eqn1= (w*r)/o==6
eqn2=(t-u)*q==8
eqn3=(1+y)/w==1
eqn4=((q*e)-0)/t==3
sol = solve([eqn1, eqn2, eqn3,eqn3], [q,w,e,r,t,y,u,i,o]);
qsol=sol.q
wsol=sol.w
esol=sol.e
rsol=sol.r
tsol=sol.t
ysol=sol.y
usol=sol.u
isol=sol.i
osol=sol.o

Respuesta aceptada

Star Strider
Star Strider el 22 de Nov. de 2021
Use the assume function —
syms q w e r t y u i o real
assume([q w e r t y u i o]>=1 & [q w e r t y u i o]<=9)
eqn1= (w*r)/o==6
eqn1 = 
eqn2=(t-u)*q==8
eqn2 = 
eqn3=(1+y)/w==1
eqn3 = 
eqn4=((q*e)-0)/t==3
eqn4 = 
sol = solve([eqn1, eqn2, eqn3,eqn3], [q,w,e,r,t,y,u,i,o], 'ReturnConditions',1);
parms = sol.parameters
parms = 
condx = sol.conditions
condx = 
qsol=sol.q
qsol = 
wsol=sol.w
wsol = 
esol=sol.e
esol = 
rsol=sol.r
rsol = 
tsol=sol.t
tsol = 
z
ysol=sol.y
ysol = 
usol=sol.u
usol = 
isol=sol.i
isol = 
osol=sol.o
osol = 
That seems to work.
Experiment to get the desired results.
.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by