Trying to solve equations within ranges
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Sulaymon Eshkabilov
2021-11-9
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!