How to Write Latitude and Longitude in MATLAB?

7 ビュー (過去 30 日間)
neilson
neilson 2015 年 10 月 20 日
回答済み: Steven 2015 年 10 月 20 日
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.

回答 (1 件)

Steven
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.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by