如何在Matlab中求解符号方程组

编程入门 行业动态 更新时间:2024-10-10 19:17:11
本文介绍了如何在Matlab中求解符号方程组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道这一定是一个愚蠢的错误,但是我真的无法解决这种类型的系统:

I know it has to be a stupid error,but I really can't solve a system of this type:

b = a2*cos(q1 + q2) + a1*cos(q1) a2*sin(q1 + q2) + a1*sin(q1) d1 + d4 + q3 >> solve(b,[q1,q2,q3,q4]) Warning: The solutions are parametrized by the symbols: z1 = C_ > In solve at 190 ans = a1: [1x1 sym] d1: [1x1 sym] d4: [1x1 sym] q1: [1x1 sym] q2: [1x1 sym] q3: [1x1 sym] q4: [1x1 sym]

基本上,我希望我的程序将a1,d1,d4视为参数,并将q1,q2,q3,q4视为变量. 这就是为什么我以这种形式调用resolve(b,[q1,q2,q3,q4])的原因,但是它甚至尝试在我没有放入向量中的符号值中进行求解.

basically I want my program to see a1,d1,d4 as parameters and q1,q2,q3,q4 as variables. that's why I call solve(b,[q1,q2,q3,q4]) in this form,but it tries to solve even in the symbolic values that I haven't put into the vector.

请寻求帮助.

推荐答案

根据的提示solve :

...调用[b,a] = solve(eqns,b,a)分配给a的解和分配给b的b的解.

... the call [b,a] = solve(eqns,b,a) assigns the solutions for a assigned to a and the solutions for b assigned to b.

然而,您可能只想求解b - [e1 e2 e3]' = 0的3个变量(假设q1 q2 q3),却无法求解4个变量,这将是3个方程式和4个没有意义的变量.

However you probably want to solve, b - [e1 e2 e3]' = 0 for only 3 variables (Let's say q1 q2 q3), you can't solve it for 4 variables, that would be 3 equations and 4 variables which does't make sense.

由于我认为这与某些机械系统有关,因此您可能只想求解实际值.您可以执行solve (eqn, 'Real', true)或声明实际值:syms a1 a2 ... real.

Since I think that it is related to some mechanical system you may want to solve for only real values. You can either do this solve (eqn, 'Real', true) or declare real values: syms a1 a2 ... real.

但是,除非在这种情况下使用'IgnoreAnalyticConstraints'选项,否则您仍然无法获得不错的结果:

However you still wouldn't get a pretty result, unless you use the 'IgnoreAnalyticConstraints' option in this case:

syms q1 q2 q3 d1 d4 a1 a2 e1 e2 e3 real b = [... a2*cos(q1 + q2) + a1*cos(q1) a2*sin(q1 + q2) + a1*sin(q1) d1 + d4 + q3]; res = solve(b-[e1 e2 e3]', q1, q2, q3, 'IgnoreAnalyticConstraints', true);

输出:(简体)

>> simplify(res.q1) ans = 2*atan((2*a1*e2 + (- a1^4 + 2*a1^2*a2^2 + 2*a1^2*e1^2 + 2*a1^2*e2^2 - a2^4 + 2*a2^2*e1^2 + 2*a2^2*e2^2 - e1^4 - 2*e1^2*e2^2 - e2^4)^(1/2))/(a1^2 + 2*a1*e1 - a2^2 + e1^2 + e2^2)) 2*atan((2*a1*e2 - (- a1^4 + 2*a1^2*a2^2 + 2*a1^2*e1^2 + 2*a1^2*e2^2 - a2^4 + 2*a2^2*e1^2 + 2*a2^2*e2^2 - e1^4 - 2*e1^2*e2^2 - e2^4)^(1/2))/(a1^2 + 2*a1*e1 - a2^2 + e1^2 + e2^2)) >> res.q2 ans = -2*atan(((- a1^2 + 2*a1*a2 - a2^2 + e1^2 + e2^2)*(a1^2 + 2*a1*a2 + a2^2 - e1^2 - e2^2))^(1/2)/(- a1^2 + 2*a1*a2 - a2^2 + e1^2 + e2^2)) 2*atan(((- a1^2 + 2*a1*a2 - a2^2 + e1^2 + e2^2)*(a1^2 + 2*a1*a2 + a2^2 - e1^2 - e2^2))^(1/2)/(- a1^2 + 2*a1*a2 - a2^2 + e1^2 + e2^2)) >> res.q3 ans = e3 - d4 - d1 e3 - d4 - d1

更多推荐

如何在Matlab中求解符号方程组

本文发布于:2023-11-30 06:11:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648983.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方程组   符号   如何在   Matlab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!