Solve 2 equation with 2 unknows, solve doesn't work.
Show older comments
I have a function as shown below. The variables inside "pinch()" are all known values. I have two equations(eqn1 & eqn2) and two unknowns(xt & yt). It seems that I'm using solve in a wrong way because I get very very very long numbers as answer and a warning "Possibly spurious solutions. [solvelib::checkVectorSolutions]". What am I doing wrong? I appreciate any help.
Thank you.
function [sol_xt,sol_yt,sol_zt] = pinch(x1,y1,z1,az1,el1,lat1,lon1, x2,y2,z2,az2,el2,lat2,lon2);
k1 = tand(az1)
k2 = tand(az2)
A1 = k1*sind(lat1)*cosd(lon1)-sind(lon1)
B1 = k1*sind(lat1)*sind(lon1)+cosd(lon1)
C1 = k1*cosd(lat1)
A2 = k2*sind(lat2)*cosd(lon2)-sind(lon2)
B2 = k2*sind(lat2)*sind(lon2)+cosd(lon2)
C2 = k2*cosd(lat2);
syms xt yt;
R1 = sqrt( (xt-x1)^2 + (yt-y1)^2 )
R2 = sqrt( (xt-x2)^2 + (yt-y2)^2 )
eqn1 = (xt-x1)*A1 + (yt-y1)*B1 - C1*tand(el1)*R1 == 0
eqn2 = (xt-x2)*A2 + (yt-y2)*B2 - C2*tand(el2)*R2 == 0
eqns = [eqn1, eqn2];
vars = [xt yt];
[sol_xt, sol_yt] = solve(eqns, vars)
sol_zt1 = R1*tand(el1) + z1
sol_zt2 = R2*tand(el2) + z2
sol_zt = (sol_zt1+sol_zt2) / 2
end
Answers (0)
Categories
Find more on Structural Mechanics 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!