Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

equivalent assume() in R2011 version

1 visualización (últimos 30 días)
studentU
studentU el 18 de Mayo de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
hi,
what is the equivalent of assume() function, to define some condition for resolving a systeme of equation?

Respuestas (1)

Walter Roberson
Walter Roberson el 19 de Mayo de 2015
evalin(symengine, 'assume(TheCondition)')
or
feval(symengine, 'assume', TheCondition)
  4 comentarios
studentU
studentU el 19 de Mayo de 2015
Editada: Walter Roberson el 19 de Mayo de 2015
this is the result:
s = symengine
evalin(s, 'Pi')
s =
MuPAD symbolic engine
ans =
Pi,
so, my problem is to find a and b; / -pi<a<pi and -pi/2<b<pi/2;
i had try :
syms G F X2 X3 el a b
[a,b] = solve('G*cos(y)+F*sin(y)=1',' cos(y)*sin(el)-sin(y)*X2*cos(x)-sin(y)*X3*sin(x)=1','-pi/2<b','b<pi/2','-pi<a','a<pi');
it's generate the error;
and i try to refine the parameter when i evaluate it:
syms G F X2 X3 el a b
[a,b] = solve('G*cos(y)+F*sin(y)=1',' cos(y)*sin(el)-sin(y)*X2*cos(x)-sin(y)*X3*sin(x)=1')
evalin(a,'-pi<a & a<pi');
but isn't the true way! have u a another proposition?
in this case, can i use fminbnd() function, and how can i use it?
Walter Roberson
Walter Roberson el 19 de Mayo de 2015
syms G F X2 X3 el a b x y
evalin(symengine, 'assume(-PI < a and a < Pi and -PI/2 < b and b < PI/2');
[a, b] = solve(G*cos(y)+F*sin(y) - 1, cos(y)*sin(el)-sin(y)*X2*cos(x)-sin(y)*X3*sin(x) - 1, a, b);
You should still expect poor results, as you are trying to solve for the value of two variables, a and b, that do not appear in the equations.
If you were to change the x and y to a and b, a solution is possible. However, the solution would be in terms of the F, G, el, X2, X3 variables, and unless you put assumptions on those variables (especially on F and G) it is not possible to figure out where the values would end up.
Supposing that you are trying to solve for x and y instead of a and b, then there are four solutions under the assumptions of real values. The code to generate them is:
t1 = (G ^ 2);
t2 = (F ^ 2);
t5 = sqrt((t1 * (t2 + t1 - 1)));
t6 = F + t5;
t8 = sin(el);
t9 = t8 ^ 2;
t12 = 2 * t9 * t5 * F;
t16 = ((t2 + 1) * t1 + t2 - 1) * t9;
t17 = X2 ^ 2;
t18 = X3 ^ 2;
t19 = (t17 + t18);
t20 = G - 1;
t21 = t20 ^ 2;
t23 = G + 1;
t24 = t23 ^ 2;
t25 = t19 * t21 * t24;
t29 = sqrt(-(-t12 + t16 - t25) * t18 * t1);
t30 = X2 * t6 * t29;
t31 = t18 * t8;
t32 = t20 * t23;
t33 = F * t5;
t34 = t33 - t1;
t36 = t31 * t32 * t34;
t38 = 1 / t19;
t40 = 1 / t6;
t43 = 1 / G;
t46 = 1 / (t1 - 1);
t47 = 1 / X3 * t43 * t46;
t51 = F * t1 * X2 * t8;
t53 = t8 * t5 * X2;
t56 = t43 * t46;
t59 = 1 / (t2 + t1);
t71 = F - t5;
t76 = sqrt(-t18 * (t12 + t16 - t25) * t1);
t77 = X2 * t71 * t76;
t78 = t33 + t1;
t80 = t31 * t32 * t78;
t83 = 1 / t71;
x1 = atan2((-t30 - t36) * t38 * t40 * t47, (-t51 + t53 + t29) * t38 * t56);
x2 = atan2((t30 - t36) * t38 * t40 * t47, (-t51 + t53 - t29) * t38 * t56);
x3 = atan2((-t77 + t80) * t38 * t83 * t47, (-t51 - t53 + t76) * t38 * t56);
x4 = atan2((t77 + t80) * t38 * t83 * t47, (-t51 - t53 - t76) * t38 * t56);
y1 = atan2(t6 * t59, -t34 * t59 * t43);
y2 = y1;
y3 = atan2(t71 * t59, t78 * t59 * t43);
y4 = y3;
Here the solution pairs are [x1,y1], [x2,y2], [x3,y3], [x4,y4]

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by