Weird results using solve function to solve the system of 2 equations
1 view (last 30 days)
Show older comments
Batir Ismailov
on 10 Jan 2015
Commented: Star Strider
on 10 Jan 2015
Hi, I'm getting weird results solving the system of two equations, can anyone pease help me or suggest the other solver?
Here is the code:
clc
close all
clear all
T_i = 0;
T_1 = 0;
T_2 = 0;
n_i = 0;
n_1 = 0;
n_2 = 0;
eNBi_coordinates = zeros(1, 2);
eNB1_coordinates = zeros(1, 2);
eNB2_coordinates = zeros(1, 2);
eNBi_coordinates = [0 100];
eNB1_coordinates = [0, 0];
eNB2_coordinates = [100, 0];
x_i = eNBi_coordinates(1);
y_i = eNBi_coordinates(2);
x_1 = eNB1_coordinates(1);
y_1 = eNB1_coordinates(2);
x_2 = eNB2_coordinates(1);
y_2 = eNB2_coordinates(2);
C = 3e8;
RSTD_1 = 167e-9;
RSTD_2 = 334e-9;
syms x_t y_t
[solx_t, soly_t] = solve(sqrt((x_t - x_i)^2+(y_t - y_i)^2)/C - sqrt((x_t - x_1)^2 + (y_t - y_1)^2)/C ...
+ (T_i - T_1) + (n_i - n_1) - RSTD_1 == 0,...
sqrt((x_t - x_i)^2+(y_t - y_i)^2)/C...
- sqrt((x_t - x_2)^2+(y_t - y_2)^2)/C + (T_i-T_2) + (n_i - n_2) - RSTD_2 == 0)
and the results i'm getting for [x_t, y_t] are:
solx_t =
(3966588620774505912890625*80204523989384538823263623044267146941326844497824520329275840654591478382575236575064977389815784125651517951641807^(1/2))/944770725576785769100984182366758081137891047164257164584802962242160716020711424 + 1631175376265062325404557393255693262302775/43556142965880123323311949751266331066368
soly_t =
1631175376265062325404557393255693262302775/43556142965880123323311949751266331066368 - (3966588620774505912890625*80204523989384538823263623044267146941326844497824520329275840654591478382575236575064977389815784125651517951641807^(1/2))/944770725576785769100984182366758081137891047164257164584802962242160716020711424
awaiting for your help.
Regards, Botir
0 Comments
Accepted Answer
Star Strider
on 10 Jan 2015
That is normal for the Symbolic Math Toolbox. If you want a simplified result, use the vpa function:
vpa_x = vpa(solx_t,6)
vpa_y = vpa(soly_t,6)
producing:
vpa_x =
75.0502
vpa_y =
-0.150251
See the documentation on vpa for details.
0 Comments
More Answers (1)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!