Input & Output, Custom Functions Solve all problems using the editor window in M
ID: 1867905 • Letter: I
Question
Input & Output, Custom Functions Solve all problems using the editor window in Matlab. With the exception of customm functions (#'s 16-18), all problems must be solved in one script file. Each custom function should be solved as a separate function file. Save your script file as: LastName_FirstName_HW1, and save your custom functions with the appropriate file names. (V250-?): -0.2 1. Define x = 10.5, so that: y--* . 0.036 2. Create and define the following variable as follows In400 +25/2 y2-1501/24.52 1.5+251V-2 3. The monthly payment M of a loan amount P for y years and with interest rate r can be calculated by the formula 12 1- 1 Write a program that calculates the monthly payment for a $100,000 loan for 30 years using a 5% interest rate. Define all independent variables (P, etc ) rather than plugging the values directly into the equation. Repeat the problem (calculate the monthly payment) for a 3% interest. Note that this equation takes interest as a decimal 4. The wind chill temperature, TwG, is the air temperature felt on exposed skin due to wind. In US customary units it is calculated by: Twc-35.740.6215T 35.75v0.360.4275Tvo.16 where T is the temperature in degrees F and v is the wind speed in mi/h. Write a Matlab program that calculates Twc. The program must define T equals to 30°F and v-42 mi/h. Write a program that calculates the dew point temperature (Td) and relative humidity (RH) for given dry-bulb (T) and wet-bulb temperatures (Tw) and barometric pressure (psta). The dew point temperature and the relative humidity RH can be calculated from the dry-bulb T and wet-bulb Tw temperatures according to the following equations 5.Explanation / Answer
The solutions for the first four subparts are given below:
MATLAB Code
clear
clc
% Problem 01
x = 10.5;
y = (2/0.036)*((sqrt(250)-x)^2/exp(-0.2));
disp(['Problem 1. For x = ',num2str(x),', the calculated value of y = ',num2str(y)])
% Problem 02
y2 = 150^(1/2) - 4.5^2*(log(400)/1.5) + 25^(1/2);
disp(['Problem 2. y2 = ',num2str(y2)])
% Problem 03
P = 100000; % amount
r1 = 0.05; % 5% = 0.05 in decimal (rate of interest)
r2 = 0.03; % 3% = 0.03 in decimal (rate of interest)
year = 30;
M1 = (P*(r1/12))/(1 - (1 + r1/12)^(-12*year));
M2 = (P*(r2/12))/(1 - (1 + r2/12)^(-12*year));
disp(['Problem 3. For r = 5%, the montly payment is ',num2str(M1),' Dollars & for r = 3%, the montly payment is ',num2str(M2),' Dollars'])
% Problem 04
T = 30; % degree F
v = 42; % mi/hr
Twc = 35.74 + 0.6215*T - 35.75*v^0.36 + 0.4275*T*v^0.16;
disp(['Problem 4. The wind chill temperature is ',num2str(Twc), ' (unit not specified)'])
Solution
Problem 1. For x = 10.5, the calculated value of y = 1914.2669
Problem 2. y2 = -63.6373
Problem 3. For r = 5%, the montly payment is 536.8216 Dollars & for r = 3%, the montly payment is 421.604 Dollars
Problem 4. The wind chill temperature is -59.5846 (unit not specified)