0% found this document useful (0 votes)
65 views15 pages

TP1 and TP2 Matlab

The document contains 8 sections with MATLAB code examples (TD1). Section 1 plots a quadratic function. Section 2 plots a sine function. Sections 3-7 demonstrate using subplot to display multiple plots. Section 8 contains additional plotting examples including contour plots and fitting data to linear and Langmuir isotherm models. The document also includes an exercise problem with experimental data that is analyzed by calculating percentage removal, absorption quantities, and fitting to linear and Langmuir isotherm models.

Uploaded by

Borith pang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views15 pages

TP1 and TP2 Matlab

The document contains 8 sections with MATLAB code examples (TD1). Section 1 plots a quadratic function. Section 2 plots a sine function. Sections 3-7 demonstrate using subplot to display multiple plots. Section 8 contains additional plotting examples including contour plots and fitting data to linear and Langmuir isotherm models. The document also includes an exercise problem with experimental data that is analyzed by calculating percentage removal, absorption quantities, and fitting to linear and Langmuir isotherm models.

Uploaded by

Borith pang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

TD1

A. Code1

x=[1:0.5:50]
y=x.^2
figure
plot(x,y)

1
B. Code2
x=[0.2:pi/4:50]
y=sin(x)
figure
plot(x,y,'b')

2
C. Code3
x=[0.2:pi/4:50]
y=sin(x-pi/4)
figure
plot(x,y,'-g')

3
D. Code4

x=[0.2:pi/4:50]
y=x.^2
w=sin(x)
z=sin(x-pi/4)
t=cos(x-pi/4)
figure
subplot(4,1,1)
plot(x,y,'.r')
subplot(4,1,2)
plot(x,w,'*b')
subplot(4,1,3)
plot(x,z,'-g')
subplot(4,1,4)
plot(x,t,'+m')

4
E. Code5
x=[0.2:pi/4:50]
y=x.^2
w=sin(x)
z=sin(x-pi/4)
t=cos(x-pi/4)
figure
subplot(2,2,1)
plot(x,y,'.r')
subplot(2,2,2)
plot(x,w,'*b')
subplot(2,2,3)
plot(x,z,'-g')
subplot(2,2,4)
plot(x,t,'+m')

5
F. Code6
x=[0.2:pi/4:50]
y=x.^2
w=sin(x)
z=sin(x-pi/4)
t=cos(x-pi/4)
figure
subplot(2,3,1)
plot(x,y,'.r')
subplot(2,3,2)
plot(x,w,'*b')
subplot(2,3,3)
plot(x,z,'-g')
subplot(2,3,5)
plot(x,t,'+m')

6
G. Code7

x=[0.2:pi/4:50]
y=x.^2
w=sin(x)
z=sin(x-pi/4)
t=cos(x-pi/4)
figure
subplot(2,3,1)
plot(x,y,'.r')
subplot(2,3,2)
plot(x,w,'*b')
subplot(2,3,3)
plot(x,z,'-g')
subplot(2,3,[4,6])
plot(x,t,'+m')

7
H. Code8
[x,y]=meshgrid(1:0.5:10,1:0.5:20)
z=x.^2+y.^2
figure
contour(x,y,z)
untiteled20
x=[30,40,60,100,120,180,240,300]
y=[1.2,0.9,0.87,0.62,0.45,0.22,0.22,0.22]
figure
plot(x,y)
untiteled17
e=[0.2:pi/6:10]
f=sin(e-(pi/4))
figure
plot(e,f)
grid

8
TP2
Exercise:
Laboratory scale of batch absorption of arsenic removal using laterite were
conducted for 24h to reach equilibrium. Table below show the data collection
during experiment. The volume of arsenic solution was 100ml.

Time(h) C1(ppm) C2(ppm) Ce1(ppm) Ce2(ppm) M1(g) M2(g)


0.5 5 10 4.85 9.58 5 10
1 5 10 4.27 8.28 5 10
2 5 10 3.98 6.57 5 10
5 5 10 1.99 4.12 5 10
7 5 10 1.01 2.18 5 10
10 5 10 0.32 1.25 5 10
12 5 10 0.18 0.67 5 10
14 5 10 0.09 0.15 5 10
15 5 10 0.07 0.09 5 10
17 5 10 0.02 0.07 5 10
20 5 10 0.01 0.05 5 10
22 5 10 0.01 0.05 5 10
24 5 10 0.01 0.05 5 10

A. Calculate percentage removal of arsenic of each condition plot those data


in subplot (function with time).
B. Calculate q of arsenic of each condition plot those data in subplot (function
with Ce).
C. Find the absorption isotherm that fit to those data and plot in subplot.

9
Answer

A. Calculate percentage removal of arsenic of each condition plot those data in


subplot (function with time).
Code
x=(a(:,2)-a(:,4)).*100./a(:,2)
w=(a(:,3)-a(:,5)).*100./a(:,3)
y=a(:,1)
figure
subplot(2,1,1)
plot(y,x,'-g')
subplot(2,1,2)
plot(y,w,'-b')

10
B. Calculate q of arsenic of each condition plot those data in subplot (function
with Ce).
Code
x=(a(:,2)-a(:,4)).*(0.1)./a(:,6)
w=(a(:,3)-a(:,5)).*(0.1)./a(:,7)
y=a(:,4)
z=a(:,5)
figure
subplot(2,1,1)
plot(y,x,'*g')
subplot(2,1,2)
plot(z,w,'+b')

11
C. Find the absorption isotherm that fit to those data and plot in subplot.
• Linear isotherm
Code
m=[0.0030;0.0146;0.0204;0.0602;0.0798;0.0936;0.0964;0.0982;0.098
6;0.0996;0.0998;0.0998;0.0998]
k=[0.0042;0.0172;0.0343;0.0588;0.0782;0.0875;0.0933;0.0985;0.099
1;0.0993;0.0995;0.0995;0.0995]
u=[4.85;4.27;3.98;1.99;1.01;0.32;0.18;0.09;0.07;0.02;0.01;0.01;0
.01]
v=[9.58;8.28;6.57;4.12;2.18;1.25;0.67;0.15;0.09;0.07;0.05;0.05;0
.05]
n=1
p=polyfit(u,m,n)
a=p(1)
b=p(2)
x=u
q=polyfit(v,k,n)
e=q(1)
d=q(2)
z=v
ymodel=a*x+b
wmodel=e*z+d
figure
subplot(2,1,1)
plot(u,m,'*r',u,ymodel)
subplot(2,1,2)
plot(v,k,'*g',v,wmodel)

12
13
• Langmuir isotherm
Code
m=[0.0030;0.0146;0.0204;0.0602;0.0798;0.0936;0.0964;0.0982;0.098
6;0.0996;0.0998;0.0998;0.0998]
k=[0.0042;0.0172;0.0343;0.0588;0.0782;0.0875;0.0933;0.0985;0.099
1;0.0993;0.0995;0.0995;0.0995]
u=[4.85;4.27;3.98;1.99;1.01;0.32;0.18;0.09;0.07;0.02;0.01;0.01;0
.01]
v=[9.58;8.28;6.57;4.12;2.18;1.25;0.67;0.15;0.09;0.07;0.05;0.05;0
.05]
n=1
h=u./m
g=v./k
p=polyfit(u,h,n)
a=p(1)
b=p(2)
x=u
q=polyfit(v,g,n)
e=q(1)
d=q(2)
z=v
ymodel=a*x+b
wmodel=e*z+d
figure
subplot(2,1,1)
plot(u,h,'*r',u,ymodel)
subplot(2,1,2)
plot(v,g,'*g',v,wmodel)

14
15

You might also like