Create two surfaces given two equations and four unknowns

I have the following code:
syms thetaA thetaB x y
A = 450;
B = 550;
x = A*sind(thetaA) - B*sind(thetaA - thetaB);
y = B*cosd(thetaA - thetaB) - A*cosd(thetaA);
I want to create two surfaces, one for thetaA and one for thetaB. The x-axis would be x, the y-axis would be y.
I know I have to solve the system of equations such that thetaA = f(x, y) and thetaB = g(x, y). Then I can create a surface from there (I haven't gotten that far yet, but I'm sure this is the easy part).
I tried to solve the system by doing:
[solthetaA, solthetaB] = solve(x == A*sind(thetaA) - B*sind(thetaA - thetaB),y == B*cosd(thetaA - thetaB) - A*cosd(thetaA));
solthetaA and solthetaB both come out as 0. This is a valid answer, yes, but is is only ONE point on the surface. I was hoping that it would give me an equation (similar to this). I know for a fact that this is going to be messy, if even possible, since you can't exactly solve for thetaA or thetaB symbolically.
The only other thing I can think of is calculating this numerically, but ideally I wanted to do this symbolically (I am doing a more complicated calculation for the later part of this, and doing it symbolically would make it easier). If I were to do this numerically, would I just use vpasolve?

Answers (1)

There ar an infinity of solutions, so the symbolic solution will return no solutions.
If you want to experiment with numeric solutions:
A = 450;
B = 550;
Eqs = @(thetaA,thetaB,x,y) [A*sind(thetaA) - B*sind(thetaA - thetaB) - x;
B*cosd(thetaA - thetaB) - A*cosd(thetaA) - y]; % Anonymous Function
x = -1:0.1:1; % Define With Appropriate Range
y = -1:0.1:1; % Define With Appropriate Range
[X,Y] = ndgrid(x,y);
for k = 1:numel(X)
angls(:,k) = fsolve(@(p)Eqs(p(1),p(2),X(k),Y(k)), randi([-180 180],2,1));
end
figure
plot(angls(1,:), angls(2,:), '.')
grid
ylim([-1 1])

2 Comments

Unfortunatley I don't have the optimization toolbox - I will see if I can download it to use fsolve. Thanks for the solution!
My pleasure.
I am not certain how you want to create the surfaces.
Perhaps:
figure
surf(X, Y, reshape(angls(1,:), size(X,1), []))
grid on
xlabel('X')
ylabel('Y')
zlabel('\theta_A (\circ)')
title('\theta_A')
Similarly for .

Sign in to comment.

Asked:

on 14 Mar 2020

Commented:

on 14 Mar 2020

Community Treasure Hunt

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

Start Hunting!