CEE 291 Problem Solving using Computer Tools Assignment

Assignment Help MATLAB Programming
Reference no: EM132463273

CEE/GLE 291 Problem Solving using Computer Tools Assignment - University of Wisconsin-Madison, USA

MATLAB Problems - Complete the following problems. Submit the code for each function. When submitting the code for a function, make sure the file is named accordingly.

Problem 1 - Write a function named getEnds which receives one vector as input. The function must return a vector containing two elements. The first element of the returned vector must be the first element of the input vector. The second element of the returned vector must be the last element of the input vector. You can assume that the input vector contains at least two elements.

Required Function Name and Parameters

getEnds(nums)

Function Call

Returned by the Function

getEnds([6,2,7,4,5,12,54,87,10,7])

[6, 7]

getEnds([4,7])

[4, 7]

getEnds([-5,-10, 4])

[-5, 4]

Problem 2 - Write a function named getMaxBelow which receives one matrix and one scalar as input. The matrix (myMatrix) contains positive and negative numbers. The scalar (limit) is an integer. The function must return the highest number in the matrix that is lower than the integer passed as the limit parameter. You can assume that at least one number in the matrix will be lower than the integer passed as the limit parameter.

Required Function Name and Parameters

getMaxBelow(myMatrix, limit)

Function Call

Returned by the Function

getMaxBelow([6,2,7,4,5,12,54,87,10,7], 50)

[12]

getMaxBelow([7], 10)

[7]

getMaxBelow([-7, -8, -3], 0)

[-3]

Problem 3 - Write a function named getDistanceToPoint which receives two vectors as input. Both vectors contain the coordinates two different points in [x, y] form. When called, the function must return the distance between the two points.

Required Function Name and Parameters

getDistanceToPoint (p1, p1)

Function Call

Returned by the Function

getDistanceToPoint([0,0], [0,1])

[1]

Problem 4 - Write a function named getDecimalAngle which receives three numbers as input. The first number (d) represents the degrees associated with the DMS representation of an angle. The second number (m) represents the minutes while the third number (s) represents the seconds. When called, the function must return the decimal form of the angle.

Required Function Name and Parameters

getDecimalAngle (d, m, s)

Function Call

Returned by the Function

getDecimalAngle(45, 30, 30.12)

[45.50836]

getDecimalAngle(15, 0, 10)

[15.00277]

Problem 5 - Write a function named getCappedValue which receives two numbers as input. If the first number received (n1) is less than or equal to the second number (n2) then the function must return n1. However, if n1 is greater than n2 then the function must return n2.

Required Function Name and Parameters

getCappedValue(n1, n2)

Function Call

Returned by the Function

getCappedValue(1, 3)

[1]

getCappedValue(5, 3)

[3]

getCappedValue(4.9999, 5)

[4.9999]

Problem 6 - Write a function named getAzimuth which receives two vectors as input. Both vectors (p1 and p2) represent a point in [x,y,z] form. The function must return the azimuth of the line in decimal form.

Required Function Name and Parameters

getAzimuth(n1, n2)

Function Call

Returned by the Function

getAzimuth([0,0,0],[1,1,1])

[45.0000]

getAzimuth([0,0,0],[0,1,1])

[0.0000]

getAzimuth([0,0,0],[-1,1,1])

[315.0000]

Problem 7 - Write a function named getDMS which receives one number as input. The number received by the function is an angle in decimal form. The function must return a 3-by-1 matrix (i.e. a vector) in which the first element represents the degrees, the second the minutes, and the third the seconds of the DMS representation of the angle.

Required Function Name and Parameters

getDMS(angle)

Function Call

Returned by the Function

getDMS(20.5)

[20, 30, 0]

getDMS(50.51)

[50, 30, 36]

getDMS(75.50275)

[75, 30, 9.9]

Problem 8 - Write a function named getAngle which receives two numbers as input. The first number (a) represents the adjacent side of a 90-deg a triangle while the second number (b) represents the opposite side. The function must return the angle (in decimal form) associated with side lengths passed as input to the function.

Required Function Name and Parameters

getAngle(a, b)

Function Call

Returned by the Function

getAngle(2, 2)

[45.0000]

getAngle(2, 4)

[26.5651]

Problem 9 - Write a function named getDivision which receives two numbers as input. The first number (n1) will be divided by the second number (n2). The function must return the division of the two numbers. However, if the division results in an Infinite (Inf) value then the function must return 1.

Required Function Name and Parameters

getDivision(n1, n2)

Function Call

Returned by the Function

getDivision(2, 2)

[1]

getDivision(2, 4)

[0.5]

getDivision(1, 0)

[1]

Problem 10 - Write a function named replaceValue which receives one matrix and two numbers as input. The function replaces instances of the first number (n1) in the matrix (m) with the second number (n2). The function must return the modified version of the matrix.

Required Function Name and Parameters

replaceValue(m, n1, n2)

Function Call

Returned by the Function

replaceValue([1,2;1,3], 1, 0)

[0,2;0,3]

replaceValue([1,2;1,3], 2, 8)

[1,8;1,3]

Problem 11 - Write a function named getColumnSum which receives one matrix and a number as input. The number (j) passed to the function represents a column in the matrix (m). The function must return the sum of the numbers in the specified column.

Required Function Name and Parameters

getColumnSum(m, j)

Function Call

Returned by the Function

getColumnSum([8,2;1,3], 1)

[9]

getColumnSum([1,2;1,3], 2)

[5]

Problem 12 - Write a function named getRowSum which receives one matrix and a number as input. The number (i) passed to the function represents a row in the matrix (m). The function must return the sum of the numbers in the specified row.

Required Function Name and Parameters

getRowSum(m, i)

Function Call

Returned by the Function

getRowSum([8,2;1,3], 1)

[10]

getRowSum([1,2;1,3], 2)

[4]

Problem 13 - Write a function named getLastItem which receives one vector as input. The function must return the last number in the vector.

Required Function Name and Parameters

getLastItem(v)

Function Call

Returned by the Function

getLastItem([8,2,1,3])

[3]

getLastItem([8,2,1,3,6])

[6]

Problem 14 - Write a function named addToEndOfVector which receives one vector and a number as input. The function must return a modified version of the vector (v) in which the number (num) has been added as the last element. The function must work even if the vector passed is empty.

Required Function Name and Parameters

addToEndOfVector(v, num)

Function Call

Returned by the Function

addToEndOfVector([8,2,1,3], 7)

[8,2,1,3,7]

addToEndOfVector([], 7)

[7]

Problem 15 - Write a function named getAscending which receives one vector as input. The function must return a modified version of the vector (v) in which the numbers are in ascending order.

Required Function Name and Parameters

getAscending(v)

Function Call

Returned by the Function

getAscending([8,2,1,3])

[1,2,3,8]

getAscending([8,2,1,3,4,4,9])

[1,2,3,4,4,8,9]

Problem 16 - Write a function named deleteColumn which receives one matrix and one number as input. The function must return a modified version of the matrix (m) with the column specified by the number (i) removed. If passed an n-by-1 matrix (i.e. a vector) and asked to delete the only column then it must return [ ] not a 3x0 empty matrix.

Required Function Name and Parameters

deleteColumn(m, i)

Function Call

Returned by the Function

deleteColumn([8,2;1,3], 1)

[2; 3]

deleteColumn([8,2,0;1,0,3], 2)

[8, 0; 1, 3]

deleteColumn([1;5;7], 1)

[]

Problem 17 - Write a function named getWithDecimals which receives two numbers as input. The first number (n1) is an arbitrary number and the second number (n2) represents a desired number of decimal places. The function must return the character array representation of n1 using n2 decimal places. Note: the process of creating a character array from multiple ones is called concatenation. In MATLAB the use of the term character array and string is often used in the same context but technically speaking these two are not the same, a common source of confusion. To the extent possible, we will use character arrays.

Required Function Name and Parameters

getWithDecimals(n1, n2)

Function Call

Returned by the Function

getWithDecimals (3.1416, 3)

'3.142'

getWithDecimals (7.23, 4)

'7.2300'

getWithDecimals (6.43, 0)

'6'

Problem 18 - Write a function named characterCount which receives a 1-by-n character array (a) and a 1-by-1 character array (c). The function must return the number of times that the character c is found in a.

Required Function Name and Parameters

characterCount(a, c)

Function Call

Returned by the Function

characterCount('abcdaa', 'a')

[3]

characterCount('abca', 'x')

[0]

Problem 19 - Write a function named flipCase which receives a character array (a) as input. The function must return a modified version of that character array in which uppercase letters become lowercase and lowercase letters become uppercase. You can assume that the only A-Z or a-z characters will be part the character array passed to the function. Finally, the result of int8('a') is 97 and the result of int8('A') is 65. Similarly, the result of char(65) is 'A' and the result of char(97) is 'a'.

Required Function Name and Parameters

flipCase(a)

Function Call

Returned by the Function

flipCase('aBc')

'AbC'

flipCase('adc')

'ADC'

flipCase('AAc')

'aaC'

Problem 20 - Write a function named getDistanceToPlane that receives four 1-by-3 matrices (i.e. vectors) named b, r, s, and t. Each vector represents the x-y-z coordinates of a point in space. The points represented by b, r, and s are on a plane. Your function must return the absolute value of the perpendicular distance between the point represented by t and the plane defined by b, r, and s.

Required Function Name and Parameters

getDistanceToPlane(b, r, s, t)

Function Call

Returned by the Function

getDistanceToPlane([0,0,0], [0,1,0], [1,0,0], [1,1,1])

[1]

Reference no: EM132463273

Questions Cloud

What type of audit evidence is used for the audit procedure : What type of audit evidence is used for the audit procedure?Audit Procedure: Trace from receiving reports to vendors' invoices and entries in the acquisitions
Determine the breakeven point in sales dollars : Determine the breakeven point in sales dollars.Determine the required sales in dollars to earn a before-tax profit of $8,000,000.
Systematic understanding of research methodology : Systematic understanding of research methodology and practice and develop a research proposal with a clear aim, set of objectives and methodology
Calculate the first years depreciation expense : Determine What are the book values for each of the individual years of useful life of the bus under the Double-Declining Balance Method?
CEE 291 Problem Solving using Computer Tools Assignment : CEE/GLE 291 Problem Solving using Computer Tools Assignment Help and Solution - University of Wisconsin-Madison, USA. Write a function named getEnds
Classified balance sheet : Classified balance sheet. Assume that $16,864 of the note payable will be paid in 2023. (List Current Assets in order of liquidity and Property, Plant)
ENGT 5214 Study Skills and Research Methods Assignment : ENGT 5214 Study Skills and Research Methods Assignment Help and Solution, De Montfort University - Assessment Writing Service - concise literature survey.
Determine not the primary purpose of an audit documentation : Determine not the primary purpose of an audit documentation,To assist in preparation of the audit report, To provide evidence of the audit work performed
How are the assets and liabilities of blair reported : Blair Company acquires all of the assets and liabilities of Tomlinson Corporation, in a transaction reported as a merger. How are the assets and liabilities

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Construct a fragment of matlab code that will prompt

Construct a fragment of MATLAB code that will prompt the student for his or her choice, read in the choice, and use the answer.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Derive the formulae for the slope and curvature

ENG3104 Engineering Simulations and Computations - Derive the formulae for the slope ( v'), curvature (v'') and v''' of the beam from Eq. (1) and Estimate the value of the slope at the second measurement point using backward, forward and central diff..

  Create an m-file that demonstrates the Law of Large Numbers

Create an m-file that demonstrates the Law of Large Numbers by taking a uniform random variable from 0 to 10

  Matlab code to create the global stiffness matrix

Write a MATLAB code to create the global stiffness matrix for a problem with 6 unconstrained degrees of freedom for any linear elastic two dimensional trusses.

  Approximate the solution to the above initial value problem

1. dydt te3t - 2y 0 le t le 1 y0 0approximate the solution to the above initial value problem usinga modified-euler

  Create a function called freefall

Write a function called eapprox that takes the value of K as input and which them approximates e using the method described.

  Find the z value needed to solve the problem

The average reflected light value found for 25 red marbles is found to be 25.7. It is known the standard deviation for the marble population is 2.9.

  MATLAB Graphical User Interface Task

MATLAB Graphical User Interface Task - Plot Velocity (cm/s) 'vs' time (ms) with appropriate plot title, x-label, and y-label

  A good way to structure this program

A good way to structure this program is to read in each "number" as a string of characters, look at the first character to determine what kind of number it is (hex, binary, decimal), and then call an appropriate function to convert the string into..

  Matlab – discrete time simulation

MATLAB – Discrete time simulation, solve  Discrete time syetm problem,  DT kalman filter problem,  Steady state DT kalman filter problem

  Calculate the geometric mean of numbers

Write a program to calculate the geometric mean of numbers entered by a user. The program should prompt the user to enter numbers and continue to accept the numbers until the user enters 999.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd