【发布时间】:2025-12-17 03:45:02
【问题描述】:
我想在 matlab 中求解一组非线性方程。我的意思是说我有两个由 (lat1,lon1) 和 (lat2,lon2) 定义的点。现在我想找到一个点 lat3,lon3 使其与这两个点相距 20 公里。它是由以(lat1,lon1)和(lat2,lon2)点为中心绘制的半径为20km的圆的交点给出的。
但是,我对如何求解这个方程有点困惑。
我有计算matlab中两点距离的功能
function [ distance ] = calculateDistance( latitude1,longitude1,latitude2,longitude2 )
radius = 6371;
dLat = degtorad(latitude2-latitude1);
dLon = degtorad(longitude2-longitude1);
a = sin(dLat/2) * sin(dLat/2) + cos(degtorad(latitude1)) * cos(degtorad(latitude2)) * sin(dLon/2) * sin(dLon/2);
c = 2 * atan2(sqrt(a), sqrt(1-a));
distance = radius * c;
end
我正在尝试使用 matlab 的求解功能 http://www.mathworks.com/help/toolbox/symbolic/solve.html
但是当我定义
syms lat3 lon3
并尝试将方程传递给求解函数,它会引发错误
atan2 only accepts arguments of type sym。
我该怎么办?
【问题讨论】: