I'm trying to set up a problem. I have two equations:
cos(q1) + cos(q1 + q2) = [x1:x2] and sin(q1) + sin(q1 + q2) = [y1, y2] where x1,x2 are endpoints of horizontal ranges and y1, y2 are endpoints of vertical ranges. All are between -2 and 2. I want to find ranges of angles of q1 and q2 that'll work within these parameters. and x2 - x1 does not equal y2 -y1.

 채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 9일

0 개 추천

One of the viable solutions is to use symbolic math: syms and solve.
clearvars; clc
x1=-2; x2=2;
y1=-2.1; y2=2.1;
x = x1:0.1:x2;
y = linspace(y1, y2, length(x));
syms q1 q2
Angle1 = zeros(length(x), 2);
Angle2 = Angle1;
for ii = 1:numel(x)
Eq1 = cos(q1) + cos(q1 + q2) == x(ii);
Eq2 = sin(q1) + sin(q1 + q2) == y(ii);
SOL = solve(Eq1, Eq2);
Q1=[double(SOL.q1(1,1)), double(SOL.q1(2,1))];
Q2=[double(SOL.q2(1,1)), double(SOL.q2(2,1))];
Angle1(ii, 1) =Q1(1); Angle1(ii, 2) =Q1(2);
Angle2(ii, 1) =Q2(1); Angle2(ii, 2) =Q2(2);
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2021b

태그

Community Treasure Hunt

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

Start Hunting!

Translated by