Programming for Engineers (MATLAB)
Laboratory 4 - Formatted Output
Objectives: Demonstrate ability to produce a specified table of output. Demonstrate ability to convert a flowchart into a working MATLAB script file.
Exercise A
Data for several moons orbiting several different planets in our solar system is stored in the file L:\engr1120\MATLABCraveMmoons.mat Use the formulas from Laboratory #3 to evaluate the lunar characteristics for all moons in the data file. Assume that all of the units are consistent with those from Laboratory #3. NOTE that the equations may need to be modified slightly to accommodate different vector variables, if applicable. Also, modify the output so that a table is produced using the exact format defined below, there are 5 spaces between columns.
Lunar Angular
Radius Velocity Period
(m) (rad/sec) (days)
#.###e+## #.###e+## ###.#
Exercise B
The flowchart on the following page describes a program that will begin by defining a vector of temperature values, given in Fahrenheit. The program then converts these temperatures into the other units commonly used for temperature: Celsius, Kelvin, and Rankine. The output from this program is to be a table showing the input temperature values and the corresponding converted temperature values, in columns.
You are to convert this flowchart into a MATLAB script M-file. The output table is to be properly labeled and have values that are appropriately aligned.
Test your program with various types of temperature vectors. For example, try using:
• one scalar input value
• a row vector of evenly spaced values (using the colon operator)
• a row vector of evenly spaced values (using the linspace function)
• a row vector of random values
• a column vector of random values (what would need to be changed in your script file?)
SUBMIT: Turn in a copy of the script file and a copy of the example output for Exercise B only. For the example output you are to use at least 5 temperature values that include 0, 32, & 212°F.