Вы находитесь на странице: 1из 4

14. True/False questions: Circle the correct response for the following questions.

a. In MS Access, an action query is used to update, add, or delete records. T


b. In/Out is a built-in Yes/No data type option in MS Access. F
c. In MS Access, AutoNumber data type generates random numbers. F
d. In MS Access, a calculated field uses existing fields in a formula. T
e. The disp(a) command displays the contents of a. T
f. The transpose operator (') in MATLAB interchanges the rows and columns of a matrix. T
g. In MATLAB, x = linspace(75,950,36) creates the same vector as x = 75:25:925 F
h. The semicolon (;) suppresses output when used at the end of MATLAB commands. T
i. The only what-if analysis tool in Excel is the Scenario Manager. F
j. In VBA, Range(B2).Offset(, -1).Resize(2, 3) refers to range B1:C3. F
15. Write the MATLAB statements required to calculate
() using the following equation for values of [9,9] in steps of 0.5.
() = { 3 2 + 5 0 3 2 + 5 < 0
for t = -9:0.5:9
if t>=0 f(t) = -3*t^2+50;
else f(t) = 3*t^2+5 ;
end
end
17. Answer the following questions based on the given MATLAB function definition
. function [a, b, c] = SampleFun(X, Y)
X = a+b+c;
Z = sqrt(X)+a^b;
Y = Z-X;
a. What is the name of the function? SampleFun
b. How many input arguments are there? 2
c. What are the input arguments? X,Y
d. How many output arguments are there? 3
e. What are the output arguments? a, b, c
f. What must be the first word in a MATLAB function file? function
g. May comments be used within a function file? Yes
h. Should clc or clear commands be in a function? No
i. Is an end statement necessary in a function? No
j. Will this function work? If not, why? No, values of outputs (a, b, c) must be assigned in the function .

18. The Excel sheet picture on the right shows the result of a macro that automatically fills up the cells in range
A2:B13. This macro should not be accessed from any other module than the module it is defined in. Fill in the
underlined blanks in the incomplete VBA procedure below.

19. Given the following linear program (LP) formulation, write the necessary MATLAB commands that will
provide the optimal solution using the linprog function to this LP as instructed below.
Maximize subject to
50 1 + 70 2 + 503 + 704
150 1 + 200 2 = 45000
135 3 + 180 4 = 36000
1 + 2 300
3 + 4 250
1 + 3 250
2 + 4 350
1, 2, 3, 4 0
Write all of the following commands as if you are typing in a MATLAB script file.
a. Define the objective function coefficients: f = [-50; -70; -50; -70];
b. Define the constraint coefficients (use as many arrays as necessary for different types of constraints): A=[1 1
0 0;0 0 1 1;1 0 1 0;0 1 0 1] B=[150 200 0 0;0 0 135 180
] c. Define the Right-Hand-Side values of constraints (use as many arrays as necessary): a=[300; 250; 250; 350]
or a = [300 250 250 350]' b=[45000; 36000] or b = [45000 36000]'
d. Define the lower bounds on decision variables: lb = zeros(4,1)
e. Solve the LP to optimality and assign the values for x and lambda: [x,lambda] = linprog(f,A,a,B,b,lb);
f. Write the command for finding the sum of the four decision variables and assigning this value to a variable
named totalProduction: totalProduction = x(1)+x(2)+x(3)+x(4)
There are three electric power plants that supply the needs of two cities. If power plant supplies electricity to
city there is a fixed cost of dollars and the cost of each kilowatt-hour (kwh) of electricity supplied is dollars,
where = 1,2,3 and = 1,2. The arrays for the fixed cost and cost per kWh are given as below. = [50 40 30] =
[ 10 15 20 10 5 25 ]
a. Write a MATLAB
function that calculates the total cost of kWh of electric supply from plant to city such that the cost
coefficients are defined in the function instead of being input values.

b. Write the MATLAB statements that will calculate the cost of supplying 100 kWh of electricity for each plantcity pair and displays the cost in tabular format as shown below

Вам также может понравиться