How to Write Latitude and Longitude in MATLAB?
5 次查看(过去 30 天)
显示 更早的评论
Our programming assignment asked us to find the distance between two cities. We were given the cities, their latitudes and longitudes and an equation to plug in. We were also given the answers, so all we had to do was write a code that spit out answers that matched the ones given. I wrote a code that works, but gives me the incorrect answers. I am wondering if I input the latitude and longitude incorrectly. Here's an example of what was given and how I wrote it in code:
Prague's Latitude = N 50 degrees, 15 arc-minutes (1 degree = 60 arc-minutes) Prague's Longitude = E 14 degrees, 26 arc-minutes
I wrote this in code as:
pragueLatitude = 50 + (15*(1/60)); pragueLongitude = 14 + (26(1/60));
While this gave me an answer, it was not the correct answer. Is there anything I am doing wrong on the coding end? Perhaps with the direction (the N/E in the give latitude and longitude). Any help would be greatly appreciated! Thanks.
0 个评论
回答(1 个)
Steven
2015-10-20
Work it out on paper, when you find equations that work you can easily transfer it to the computer and let it do the work. It is important to be able to figure things out on paper, so that if the computer is giving the wrong answer (and they often do) you can check it.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!