You are on page 1of 6

Name: ___________________________

ID: ______________________________

CH460 Process Dynamics & Control


Sample Exam

Name: ___________________________

1.

ID: ______________________________

What are the final outputs? CIRCLE ANSWERS (20 points)


a) i=1;
k=3;
while k<5
k=k+2;
if ~(k>i) && (k<2)
i=i+2;
end
end
disp(k);
b) count_index = 6;
num_of_times=0;
for i = 1: count_index
if i>=5
num_of_times=num_of_times+1;
end
end
disp(num_of_times);

c) matrix1=[1, 2, 3, 5; 4, 5, 6, 6];
[row, column] = size (matrix1);
for i=1:row
for j=1:column
matrix2(j,i)=matrix1(i,j);
end
end
disp(matrix2);

Name: ___________________________

ID: ______________________________

2.
What are the values of variables number(1), number(2), and number(3) at the end of the
following script? CIRCLE ALL ANSWERS (20 points)
clear all
clc
number(1:3)=6;
for i= 1: 3
for j=1:i
number(i)= number(i) + j;
end
end

Name: ___________________________

ID: ______________________________

3.
The following program contain multiply syntax error circle them all. Note circle a correct syntax
code will lead to deduction of marks. (20 points)

row = input ( Please enter the number of rows in the matrix: );


column = input ( Please enter the number of columns in the matrix: );
% Ask the user to input the 1's and 0's in these for loops.
for m=1: row
for n = 1 : column
5 = input_value;
while (input_value ~= 1) && (input_value ~= 0)
ask_input = ['Please input value (0/1) for element ', num2str(m), ', ', num2str(n)];
disp (ask_input)
input_value = input ('enter the value here: ');
end
matrix(m,n) = input_value;
end
end
disp( The matrix you entered is: )
disp(matrix)

Name: ___________________________

ID: ______________________________

4.
A program is shown below. Your task is to write a new program that perform the same task and
achieve the same results by replacing the for loops with while loops. You can introduce new variables in
the new program if you need them. (20 points)
i_end=5
j_start=5
counter=1;
for i=1:i_end
for j=j_start:-1:1
counter=counter+1;
end
end

Name: ___________________________

ID: ______________________________

5.
A stirred-tank blending system is shown below. In stream 1, assume that the mass flow rate w1
is constant, but mass fraction of A (x1) varies with time. Assume stream 2 consists of pure A (x2 = 1) and
the mass flow rate w2 can be adjusted. The mass fraction of A in the outlet stream is defined as x and
the set point is xsp. (a) Identify the control strategy. (b) Briefly discuss the advantage of this control
strategy. (c) For control purpose, how to determine the sampling time of measured variables. (20
points)
(a)

C
S

(b)

You might also like