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]
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.
Ty in advice for your help.
As written, you're currently trying to solve two sets of equations. The first is the three
b
equations equal to zero. The second is the vector[q1,q2,q3,q4]
equal to zero. Because your first equation is not a function of a vector but rather of only the components of this vector,solve
sees the second argument as an equation rather than variable to solve for. To solve for the desired variables, simply list them as per the documentation:or
Now you will obtain non-zero solutions. However, you'll still get a warning as you obviously have three equations and are trying to solve for four unknowns and there are possibly an infinite number of solutions over the real numbers. In fact
q4
isn't used in these equations at all.According to tips of
solve
:However you probably want to solve,
b - [e1 e2 e3]' = 0
for only 3 variables (Let's sayq1 q2 q3
), you can't solve it for 4 variables, that would be 3 equations and 4 variables which does't make sense.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
.However you still wouldn't get a pretty result, unless you use the
'IgnoreAnalyticConstraints'
option in this case:Output: (simplified)
The correct syntax is: