Solve function is only returning one solution

I am trying to solve a system of 4 equations and 4 unknowns using the matlab solve function. I know that there are several solutions to this system of equations and I need to know more than just the one that is being returned.
syms th13 th14 th15 th16_1 th16_2 w13 w14 w15 w16 a13 a14 a15 a16
r8_4 = 1.8954067;
th8_4 = 105.9929731;
r9_2 = 9.53160604;
th9 = 129.85280129;
r10 = 6.48724184;
th10 = 49.98718547;
r11 = 0.45876947;
th11 = 163.22642382;
r13_1 = 2.231140;
r13 = 5.49701918;
r14 = 4.90813124;
r15 = 4.26848605;
r16_1 = 6.90211437;
r16_2 = 5.58711046;
r17_2 = 4.66865764;
th17 = 141.3590041;
r18 = 6.49056539;
th18 = 103.38347549;
r24 = 6.11345151;
th24 = 67.35451271;
y = 3.57084555;
th16_2 = th16_1 + y;
%% Position Vectors
real_6p_1 = r18*cosd(th18) + r17_2*cosd(th17) + r16_1*cosd(th16_1) + r14*cosd(th14) + r13_1*cosd(th13) == r24*cosd(th24) + r11*cosd(th11) + r10*cosd(th10) + r9_2*cosd(th9) + r8_4*cosd(th8_4);
imag_6p_1 = r18*sind(th18) + r17_2*sind(th17) + r16_1*sind(th16_1) + r14*sind(th14) + r13_1*sind(th13) == r24*sind(th24) + r11*sind(th11) + r10*sind(th10) + r9_2*sind(th9) + r8_4*sind(th8_4);
real_6p_2 = r18*cosd(th18) + r17_2*cosd(th17) + r16_2*cosd(th16_2) + r15*cosd(th15) + r13*cosd(th13) == r24*cosd(th24) + r11*cosd(th11) + r10*cosd(th10) + r9_2*cosd(th9) + r8_4*cosd(th8_4);
imag_6p_2 = r18*sind(th18) + r17_2*sind(th17) + r16_2*sind(th16_2) + r15*sind(th15) + r13*sind(th13) == r24*sind(th24) + r11*sind(th11) + r10*sind(th10) + r9_2*sind(th9) + r8_4*sind(th8_4);
S = solve([real_6p_1 imag_6p_1 real_6p_2 imag_6p_2], [th13 th14 th15 th16_1]);
th13 = vpa(S.th13);
th14 = vpa(S.th14);
th15 = vpa(S.th15);
th16_1 = vpa(S.th16_1);
th16_2 = vpa(th16_1 + y);

 Accepted Answer

Infinite number of solutions.
syms th13 th14 th15 th16_1 th16_2 w13 w14 w15 w16 a13 a14 a15 a16
r8_4 = 1.8954067;
th8_4 = 105.9929731;
r9_2 = 9.53160604;
th9 = 129.85280129;
r10 = 6.48724184;
th10 = 49.98718547;
r11 = 0.45876947;
th11 = 163.22642382;
r13_1 = 2.231140;
r13 = 5.49701918;
r14 = 4.90813124;
r15 = 4.26848605;
r16_1 = 6.90211437;
r16_2 = 5.58711046;
r17_2 = 4.66865764;
th17 = 141.3590041;
r18 = 6.49056539;
th18 = 103.38347549;
r24 = 6.11345151;
th24 = 67.35451271;
y = 3.57084555;
th16_2 = th16_1 + y;
%% Position Vectors
real_6p_1 = r18*cosd(th18) + r17_2*cosd(th17) + r16_1*cosd(th16_1) + r14*cosd(th14) + r13_1*cosd(th13) == r24*cosd(th24) + r11*cosd(th11) + r10*cosd(th10) + r9_2*cosd(th9) + r8_4*cosd(th8_4);
imag_6p_1 = r18*sind(th18) + r17_2*sind(th17) + r16_1*sind(th16_1) + r14*sind(th14) + r13_1*sind(th13) == r24*sind(th24) + r11*sind(th11) + r10*sind(th10) + r9_2*sind(th9) + r8_4*sind(th8_4);
real_6p_2 = r18*cosd(th18) + r17_2*cosd(th17) + r16_2*cosd(th16_2) + r15*cosd(th15) + r13*cosd(th13) == r24*cosd(th24) + r11*cosd(th11) + r10*cosd(th10) + r9_2*cosd(th9) + r8_4*cosd(th8_4);
imag_6p_2 = r18*sind(th18) + r17_2*sind(th17) + r16_2*sind(th16_2) + r15*sind(th15) + r13*sind(th13) == r24*sind(th24) + r11*sind(th11) + r10*sind(th10) + r9_2*sind(th9) + r8_4*sind(th8_4);
equation = [real_6p_1 imag_6p_1 real_6p_2 imag_6p_2];
vars = [th13 th14 th15 th16_1];
F = matlabFunction(lhs(equation)-rhs(equation), 'vars', {vars});
N = 100;
locs = zeros(N, 4);
opt = optimoptions('fsolve', 'display', 'none');
for K = 1 : N
x0 = randn(1,4)*1000;
locs(K,:) = fsolve(F, randn(1,4)*1000, opt);
end
sols = uniquetol(locs,1e-5,'byrows',true);
format long g
sols
sols = 100×4
-2835.82880818841 115.202369757362 1218.95217949277 1122.43616042426 -2475.8288082094 -604.797630229398 858.952179493162 1122.43616040863 -2441.33655450549 -2141.22142845289 -3.69784684434927 -266.002727106797 -2035.45989500304 1167.87803122431 758.874257709475 34.509044905432 -1395.82880807509 -244.797630096013 -1661.04782020201 42.4361603315934 -1395.82878142753 -2764.79759212455 1218.95222174111 -1397.56386728082 -1361.33652904002 2178.77858926081 356.302211414932 -1346.0027378551 -1315.4598951931 87.8780312147776 -681.12574227183 -325.490955082301 -1315.45989402113 447.878030545614 1118.87424357959 -325.490959932525 -1070.02979215949 -675.335881467341 -1355.50833994533 -620.964155232411

1 Comment

Within the basic range, for at least some of the variables, if x was a solution then so was 360-x

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2018b

Tags

Community Treasure Hunt

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

Start Hunting!