How to Write Latitude and Longitude in MATLAB?

5 views (last 30 days)
neilson
neilson on 20 Oct 2015
Answered: Steven on 20 Oct 2015
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.

Answers (1)

Steven
Steven on 20 Oct 2015
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.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!