Aerospace Equations Involving Logarithms, Exercises of Astronomy

Multiple line integrals descent for processes

Typology: Exercises

2022/2023

Uploaded on 11/03/2025

lalith-sasubilli
lalith-sasubilli 🇺🇸

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MAE 8 - Fall 2025
Homework 4
Instructions: Follow the homework solution template. Put all answers in a MATLAB
script named hw4.m. Create a zip archive named hw4.zip to include the following files:
hw4.m,temperature.dat,rainfall.dat,divisibility.m, and piecewise2d.m. Make sure
that both figures 1 and 2 are shown on screen when the homework script is executed. Sub-
mit hw4.zip in Canvas before 10 PM on Saturday 11/1/2025. Use double precision unless
otherwise stated.
Problem 1:
The built-in function clock returns a row vector that contains 6 elements: the first three
are the current date (year, month, day) and the last three represent the current time in
hours (24 hour clock), minutes, and seconds. The seconds is a real number, but all others
are integers. Use function sprintf to accomplish the following formatting exercises.
a) Get the current date and time and store them in p1a. The current date and time
should be the date and time when the grader calls your script.
b) Using the format 'YYYY:MM:DD', write the current date to string p1b. Here, YYYY,
MM, and DD correspond to 4-digit year, 2-digit month, and 2-digit day, respectively.
c) Using the format 'HH:MM:SS.SSSS', write the current time to string p1c. Here, HH,
MM, and SS.SSSS correspond to 2-digit hour, 2-digit minute and 7-character second (2 digits
before the decimal point and 4 digits after the decimal points), respectively.
d) Remove the last 5 characters from the string in part (c) so that the format is now
'HH:MM:SS'. Put the answer into string p1d.
e) Combine the strings in part (b) and part (d) together separated by a single space. Put
the answer in string p1e.
Problem 2:
Use the matrix matA below to perform the following exercises.
matA =
π π/4π/7
π/2π/5π/8
π/3π/6π/9
a) Write the first column of matrix matA into string p2a using a field width of 6
characters with 4 decimal places for each element. The string must show a column vector.
b) Write the middle row of matrix matA into string p2b using a field width of 5 char-
acters with 3 decimal places for each element. The string must show a row vector.
c) Write matrix matA into string p2c using a field width of 16 characters with 14 decimal
places.
d) Write matrix matA into string p2d using %e having a field width of 11 characters
with 5 decimal places.
pf3
pf4

Partial preview of the text

Download Aerospace Equations Involving Logarithms and more Exercises Astronomy in PDF only on Docsity!

MAE 8 - Fall 2025

Homework 4

Instructions: Follow the homework solution template. Put all answers in a MATLAB script named hw4.m. Create a zip archive named hw4.zip to include the following files: hw4.m, temperature.dat, rainfall.dat, divisibility.m, and piecewise2d.m. Make sure that both figures 1 and 2 are shown on screen when the homework script is executed. Sub- mit hw4.zip in Canvas before 10 PM on Saturday 11/1/2025. Use double precision unless otherwise stated.

Problem 1: The built-in function clock returns a row vector that contains 6 elements: the first three are the current date (year, month, day) and the last three represent the current time in hours (24 hour clock), minutes, and seconds. The seconds is a real number, but all others are integers. Use function sprintf to accomplish the following formatting exercises. a) Get the current date and time and store them in p1a. The current date and time should be the date and time when the grader calls your script. b) Using the format 'YYYY:MM:DD', write the current date to string p1b. Here, YYYY, MM, and DD correspond to 4-digit year, 2-digit month, and 2-digit day, respectively. c) Using the format 'HH:MM:SS.SSSS', write the current time to string p1c. Here, HH, MM, and SS.SSSS correspond to 2-digit hour, 2-digit minute and 7-character second (2 digits before the decimal point and 4 digits after the decimal points), respectively. d) Remove the last 5 characters from the string in part (c) so that the format is now 'HH:MM:SS'. Put the answer into string p1d. e) Combine the strings in part (b) and part (d) together separated by a single space. Put the answer in string p1e.

Problem 2: Use the matrix matA below to perform the following exercises.

matA =

π π/ 4 π/ 7 π/ 2 π/ 5 π/ 8 π/ 3 π/ 6 π/ 9

a) Write the first column of matrix matA into string p2a using a field width of 6 characters with 4 decimal places for each element. The string must show a column vector. b) Write the middle row of matrix matA into string p2b using a field width of 5 char- acters with 3 decimal places for each element. The string must show a row vector. c) Write matrix matA into string p2c using a field width of 16 characters with 14 decimal places. d) Write matrix matA into string p2d using %e having a field width of 11 characters with 5 decimal places.

Problem 3: Download the file rainfall.dat from CANVAS. The file includes the San Diego monthly- averaged rainfall data in inches from 1850 to 2024. The data is comma delimited. The first column indicates the year and the following 12 columns show the monthly-averaged rainfall from January through December. Load this data file into MATLAB and answer the following questions: (a, b, c) Find the highest monthly rainfall (over all months and all years) and put the answer in p3a. In what month and what year did it occur? Put the answer in p3b and p3c, respectively. For p3b, use 1 for Jan, 2 for Feb, etc. (d) Between 1900 and 2000, how many times had the monthly rainfall been between 2 and 5 in inclusively? Put the answer in p3d. (e) During the months of January between 1910 and 2010, how many times had the monthly rainfall been higher than 4 in? Put the answer in p3e.

Problem 4: Download the file temperature.dat from CANVAS. The file includes the San Diego monthly-averaged temperature data from 1852 to 2020. The data is comma delimited. The first column indicates the year and the following 12 columns show the monthly-averaged temperature from January through December. Load this data file into MATLAB. a) Extract the years into row vector p4a. b) Extract the temperatures during the months of October into row vector p4b. c) Use function mean with the result in part (b) to compute the average temperature for the months of October. Create a row vector p4c with the same length as the vector in part (a) but all elements have the average temperature value. d) During the months of October, what are the maximum and minimum temperatures? Put the answers in a 2-element row vector p4d where the first element is the maximum and the second is the minimum. e) For the months of October, during which years do the maximum and minimum tem- peratures occur? Put the answer in a 2- element row vector p4e where the first element is the year with the maximum temperature and the second is the year with the minimum temperature. f) Create figure 1 and set p4f='See figure 1'. The figure should include the following:

  • A line plot showing the temperatures for the months of October, use black solid line.
  • A line plot showing the average temperature for the months of October, use blue solid line.
  • The maximum temperature for the months of October use red square marker.
  • The minimum temperature for the months of October, use green diamond marker.
  • Give the figure a title and a legend, and label the axes.

(i) Set p6i = piecewise2d(π, 0). (j) Set p6j = piecewise2d(−π, 0).