MATLAB Part 2 Williams - Final
MATLAB Part 2 Williams - Final
Plot:
390
K=2
K=4
K=8
380
370
350
y ( C)
360
340
330
320
310
300
Time (minutes)
10
15
Grace Williams
Chemical Process Control
MATLAB Assignment #2 Part 2
Example 6:
Command Window:
>> example6
>> example6
Warning: Ignoring extra legend entries.
> In legend at 286
In example6 at 11
>> example6
Script:
plot (t,y1,'r','linewidth',2)
hold on;
plot (t,y2,'b','linewidth',2)
hold on;
plot (t,y3,'k','linewidth',2)
hold on;
plot (t,y4,'g','linewidth',2)
hold on;
xlabel('Time (minutes)','fontsize',12)
ylabel('y','fontsize',12)
legend('\tau_3=16','\tau_3=4','\tau_3=1','\tau_3=1','fontsize',12)
=16
3
=4
3
=1
3
4
=1
3
fontsize
3
2
1
0
-1
0
10
15
Time (minutes)
20
25
30
Grace Williams
Chemical Process Control
MATLAB Assignment #2 Part 2
Example 7:
Command window:
>> example7
>> example7
Script:
plot (t,y,'r','linewidth',2)
xlabel('Time (minutes)','fontsize',12)
ylabel('y (mm)','fontsize',12)
20
15
10
5
y (mm)
0
-5
-10
-15
-20
-25
-30
10
20
30
40
50
Time (minutes)
60
70
80
Grace Williams
Chemical Process Control
MATLAB Assignment #2 Part 2
Example 8:
Command window:
>> example8
Script:
plot (t,L1,'r','linewidth',2)
hold on;
plot (t,L2,'b','linewidth',2)
hold on;
plot (t,L3,'k','linewidth',2)
hold on;
xlabel('Time (minutes)','fontsize',12)
ylabel('L (mm)','fontsize',12)
legend('L1 model','L2 model','L3 model')
100
L1 model
L2 model
L3 model
80
L (mm)
60
40
20
-20
10
15
20
25
30
Time (minutes)
35
40
45
50
Grace Williams
Chemical Process Control
MATLAB Assignment #2 Part 2
Problem 4:
1. Plot the T profile:
25
20
y ( C)
15
10
50
100
150
Time (minuites)
200
250
300
Script:
syms t
laplace(25*heaviside(t-50)-25*heaviside(t-100))
syms s;
Y_s=((25*exp(-50*s))/s - (25*exp(-100*s))/s)/(10*s+1);
y_t1=ilaplace(Y_s);
t1=0:0.1:300;
y_t1=25*heaviside(t1 - 100).*(exp(10 - t1/10) - 1) - 25*heaviside(t1 50).*(exp(5 - t1/10) - 1);
plot(t1,y_t1,'linewidth',2)
xlabel('Time (minuites)','fontsize',12);
ylabel('y (^oC)','fontsize',12);
Command Window:
>> Problem4
Error: File: Problem4.m Line: 2 Column: 13
Unbalanced or unexpected parenthesis or bracket.
>> Problem4
ans =(25*exp(-50*s))/s - (25*exp(-100*s))/s
Grace Williams
Chemical Process Control
MATLAB Assignment #2 Part 2
>> Problem4
Error: File: Problem4.m Line: 4 Column: 49
Unexpected MATLAB expression.
>> Problem4
ans =(25*exp(-50*s))/s - (25*exp(-100*s))/s
>> Problem4
ans =(25*exp(-50*s))/s - (25*exp(-100*s))/s
>> Problem4
ans = (25*exp(-50*s))/s - (25*exp(-100*s))/s
y_t1 =25*heaviside(t - 100)*(exp(10 - t/10) - 1) - 25*heaviside(t - 50)*(exp(5 - t/10) 1)
>> Problem4
ans =(25*exp(-50*s))/s - (25*exp(-100*s))/s
y_t1 =25*heaviside(t - 100)*(exp(10 - t/10) - 1) - 25*heaviside(t - 50)*(exp(5 - t/10) - 1)
y_t1 =25*heaviside(t - 100)*(exp(10 - t/10) - 1) - 25*heaviside(t - 50)*(exp(5 - t/10) - 1)
Error using plot
Conversion to double from sym is not possible.
Error in Problem4 (line 8)
plot(t1,y_t1,'linewidth',2)
>> Problem4
ans =(25*exp(-50*s))/s - (25*exp(-100*s))/s
2. Use Simulink model to determine the T profile.
25
Laplace Transform approach
Simulink Simulation approach
20
y ( C)
15
10
Script:
t1 = 0:0.1:300;
50
100
150
Time(minutes)
200
250
300
Grace Williams
Chemical Process Control
MATLAB Assignment #2 Part 2
y_t1=25*heaviside(t1 - 100).*(exp(10 - t1/10) - 1) - 25*heaviside(t1 50).*(exp(5 - t1/10) - 1);
plot(t1,y_t1,'linewidth',2);
hold on
plot(t2,y_t2,'r+','linewidth',2)
xlabel('Time(minutes)','fontsize',12);
ylabel('y (^oC)','fontsize',12);
legend('Laplace Transform approach','Simulink Simulation approach')
Command Window:
>> Problem4part2
>> Problem4part2
>> Problem4part2
Script file: Problem4part2
Simulink file: Problem4simulink
3. Step change in Q:
40
1/wC = 0.05
1/wC = 0.025
1/wC = 0.075
35
Temperature ( C)
30
25
20
15
10
5
0
50
100
150
Time(minutes)
200
250
300
**With a larger K value, the larger the temperature difference and it increases the steady state value
increases. However, there is no change in time to reach steady state, because the time constant is staying
the same. With the new step change, there was no delay in reaching steady state.
Script:
plot(t,y_t2,'r','linewidth',2)
Grace Williams
Chemical Process Control
MATLAB Assignment #2 Part 2
hold on;
plot(t,y_t1,'b','linewidth',2)
hold on;
plot(t,y_t3,'k','linewidth',2)
xlabel('Time(minutes)','fontsize',12)
ylabel('y (^oC)','fontsize',12)
legend('1/wC = 0.05','1/wC = 0.025','1/wC = 0.075')
Command Window:
>> Problem4part3
>> Problem4part3
Warning: Using a default value of 6.0 for maximum step size. The simulation step size will be equal
to or less than this value. You can disable this diagnostic by setting 'Automatic solver parameter
selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters dialog
>> Problem4part3
>> Problem4part3
>> Problem4part3
Script file:Problem4part3
Simulink file: Problem4simulinkpart3