You are on page 1of 9

AME 3723-002 HW #1 Report

Name: Janella Clary


4x4: clar9363
HW 1-MATLAB Programming Lab Review
Problem 1: Write a program to calculate expressions (a) through (d)
Approach: Write expressions keeping in mind the order of operations.
Command Window Results:

Editor Window:

Problem 2: Write a program to calculate the distance between two


coordinates

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363

Approach: Ask the user for coordinate inputs which are stored as 4
different variables. Implement an equation that relates these variables to
calculate distance
Command Window:

Editor Window:

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363

Problem #3: Write a program that shows the piecewise functions depending on the value input by users
Approach: Create variables using user input. Use if and elseif statements to output functions depending on the
values of the variables and a while loop to run code multiple times.
Command Window:

Editor Window:

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363

Problem 4: Determine max, min, and variance of the array


Approach: Use a for loop to determine the max and min and total of the array. Use a different for loop for
variance so that the final mean is used instead of changing it up with each iteration.
Command Window:

Editor Window:

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363

Problem 5: Create a matrix whose values are based on the values of the indices
Approach: Create a matrix of zeros, then replace them with values based on the value of the indices. Use an if
statement to assign values depending on whether the sum is odd or even as determined by mod operator.
Command Window:

Editor Window:

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363

Problem 6: Write a program to plot a function and its derivatives


Approach: Use various functions for plotting found on MTALAB website to create a labeled graph on
appropriate axes with certain markers. Plot on the same graph by using a single plot function.
Command Window:

Editor Window:

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363
Problem 7: Write a program that creates and implements a user defined function
Approach: Use a for loop to keep increasing accuracy of cos approximation depending on the
value of n entered by user
Command Window:

Editor Window:

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363

AME 3723-002 HW #1 Report


Name: Janella Clary
4x4: clar9363

You might also like