Question 1 - Answer problems 1, 2, 3 and 4 -
1. Write a user-defined MATLAB function for the following math function: y(x) = 0.6x3e-0.47x + 1.5x2e-0.6x
The input to the function is x and the output is y. Write the function such that x can be a vector (use element-by-element operations).
(a) Use the function to calculate y(-2) and y(4).
(b) Use the function to make a plot of the function y(x) for -4 ≤ x ≤ 8.
2. Write a user-defined MATLAB function for the following math function: r(θ) = 3 sin(3cos(0.5θ))
The input to the function is θ (in radians) and the output is r. Write the function such that θ can be a vector.
(a) Use the function to calculate r(π/6) and r(5π/6).
(b) Use the function to plot (polar plot) r(θ) for 0 ≤ 0 ≤ 4π.
3. In the U.S. fuel efficiency of cars is specified in miles per gallon (mpg). In Europe it is often expressed in liters per 100 km. Write a MATLAB user-defined function that converts fuel efficiency from mpg to liters per 100 km. For the function name and arguments, use Lkm = mpgToLpkm (mpg). The input argument mpg is the efficiency in mi/gl, and the output argument Lkm is the efficiency in liters per 100 km (rounded to the nearest hundredth). Use the function in the Command Window to:
(a) Determine the fuel efficiency in liters per 100 km of a car whose fuel efficiency is 21 mi/gal.
(b) Determine the fuel efficiency in liters per 100 km of a car whose fuel efficiency is 36 mi/gal.
4. Pressure in U.S. customary units is measured in psi (pound per square inch).
In SI metric units pressure is measured in Pa (N/m2). Write a user-defined MATLAB function that converts pressure given in units of psi to pressure in units of Pa. For the function name and arguments, use [Pa] = Psi - ToPa (psi). The input argument psi is the pressure in units of psi to be converted, and the output argument Pa is the converted pressure in units of Pa (rounded to the nearest integer). Use the function in the Command Window to:
(a) Convert 120 psi to units of Pa.
(b) Convert 3,000 psi to units of Pa.
Question 2 - Solve the following second-order differential equation - x·· +2ζωnx· + ωn2x = Asin(ωt)
Where x· = dx/dt, x·· = d2x/dt2, ζ = 0.5, ωn = 40 rad/s, A = 80, ω = 50. Use the function ode45() with 0 ≤ t ≤ 10s. Plot x and x· versus time on the same page and use the appropriate labels.
Question 3 - Compute the following indefinite integral
I(x) = ∫((x(x+1))½/√x+√(1+x)) dx