ASEN4090 Lab 1: Matlab Review


Due: in class September 2

Description: The purpose of this assignment is to have you practice your Matlab on a simple problem relevant to GPS. I have given you instructions so that your code is modular, i.e. you should get in the habit of developing simple functions so you can use them over and over again. To make that easier, it is important that you define the input and output (I/O) of each function at the top of the code. Defining the I/O also means you need to define the units.

You should always have a main program. You will turn this in along with your Cartesian-Lat/Long/Height function. Your code will be graded based on completeness (did you do everything I asked you to do?), correctness, and adequateness of commenting (i.e. Did you define the I/O, did you include your name on the code?)

You will be writing a function that converts Cartesian positions (X,Y,Z) in meters to Latitude (radians), Longitude (radians), and Height h(meters). The mathematical equations you are going to solve to find out your final location require that you use Cartesian coordinates. But, in the real world no one wants to know their Cartesian coordinates, so you need to be able to translate from Cartesian to Lat/Long/Ht. Note: I also have code that translates Lat/Long/Ht into Cartesian coordinates, but you won't need it for this class.

If the Earth was a sphere, the transformation between Cartesian and Lat/Long/Ht would be trivial. Because the Earth is an oblate spheroid, you need to iterate to determine the correct Lat/Long/Ht. Rather than one value for the Earth's radius, we use two values, the equatorial radius (a = 6378137.0 meters) and the polar radius (b = 6356752.31425 meters).

One final complication regards the definition of tangent. If you remember back to trigometry, there are 4 quadrants. In order to avoid the ambiguities as to which quadrant you are in, use the Matlab function atan2 rather than atan. If you have never used atan2, type help atan2.

The algorithm:

Test Cases:

Use your code on these coordinates (which should be defined in your main code). The answers are returned to your main function and printed to the screen there.

  1.   302737.6281 5636031.5538 2979349.8064

  2.   -1283388.8693 -4713016.9053 4090191.0471

  3.   -2389025.4954 5043316.8722 -3078530.7858
Submit your answers in degrees (for latitude and longitude) with 7 digits beyond the decimal point. Height should be given in meters to 4 digits beyond the decimal point.

Hints: