# Solving for different thetas in an equation.

조회 수: 2(최근 30일)
Max Rivera 2021년 7월 17일
편집: John D'Errico 2021년 7월 18일
I was wondering if there was any way to determine multiple angles in an equation to make an equation true.
For example, an equation like: -4sin(theta1) - 6sin(theta2) + 5sin(theta2) = -3
or 4cos(theta1) + 6cos(theta2) + 5cos(theta3) = 12

댓글을 달려면 로그인하십시오.

### 답변(2개)

DGM 2021년 7월 17일
편집: DGM 2021년 7월 18일
If you have a sufficient amount of information to describe the number of variables, then yes. If I make some assumptions:
% assuming that the equations given are not independent
% but constitute a system of equations
syms theta1 theta2
eq1 = -4*sin(theta1) - 6*sin(theta2) + 5*sin(theta2) == -3
eq1 =
% assuming that theta3 was a typo
eq2 = 4*cos(theta1) + 6*cos(theta2) + 5*cos(theta2) == 12
eq2 =
S = solve([eq1 eq2],[theta1 theta2])
S = struct with fields:
theta1: [2×1 sym] theta2: [2×1 sym]
S.theta1 % there are two solutions
ans =
S.theta2
ans =
If the assumptions that I made above do not apply, then refer to John's answer.
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

John D'Errico 2021년 7월 18일
편집: John D'Errico 2021년 7월 18일
You CANNOT solve for both theta1 and theta2 in a single equation like that. (I assume you meant a single equation, because you had the word OR in between the pair of equations you showed.) At best, you can solve for one variable in terms of the other. But effectively, what I will do here will allow you to generate infinintely many solution pairs, and do so trivially.
By the way, learn to use an asterisk to denote multiplication. Here is one of the equations you posed as an example:
syms theta1 theta2
E = -4*sin(theta1) - 6*sin(theta2) + 5*sin(theta2) == -3;
We can now simply solve for theta1, if we knew theta2. That is, we can do:
theta1 = solve(E,theta1)
theta1 =
So there are two solutions. At least they may be real solutions.
fplot(theta1(1),[-pi,pi],'r-')
hold on
fplot(theta1(2),[-pi,pi],'b-')
legend('Solution1','Solution 2')
xlabel Theta2
ylabel Theta1
So the two solutions cross at a point. As long as you know theta2, you can compute TWO solutions for theta1. And then there would be infinitely more solutions at multiples of 2*pi up or down.
Essentially, you can pick ANY value for theta2, that gives you two primary solutions for the other. Any such equation will work the same way, although it may not be as trivial to solve. If you want to generate a list of solutions, then just pick a list for theta2...
theta2list = linspace(-pi,pi,100);
Now substitute those elements into the solution, computing a a pair of solutions for every theta2.
What I did above was little more complicated than if you had posed the problem
theta1 + 2*theta2 == 3
Surely you would know how to deal with that?

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by