Escolar Documentos
Profissional Documentos
Cultura Documentos
SIDHARTH RAZDAN
04316101410
USCT 3rd YEAR
EXPERIMENT NO. 1
EXPERIMENT NO. 2
2 -3
X=
x
y
z
and, B=
9
13
40
In the command window, we enter the component matrix A and use matrix algebra to
calculate vector X as,
>> A= [ 1 1 1 ; 2 -3 4 ; 3 4 5 ] ;
>> B= [ 9 ; 13 ; 40 ] ;
>> X= A \ B
If we are to use the fsolve method, we define a .m file, say linf2.m, as follws
function m=linf2(p)
x = p(1); y = p(2); z = p(3);
m= zeros (3,1);
m(1)= x + y + z 9 ;
m(2)= 2*x - 3*y + 4*z - 13 ;
m(3)=3*x + 4*y + 5*z - 40 ;
In the command window we use the function fsolve as follows,
>> fsolve ( @linf2, [ 0 0 0 ] )
The vector [ 0 0 0 ] denotes the initial assumptions of x, y, z as 0, 0, 0 respectively.
RESULT:
For the matrix method, we get
X=
1.0000
2.0000
3.0000
For the method using fsolve, we get
ans=
1.0000
2.0000
3.0000
EXPERIMENT NO. 3
PRECAUTIONS:
EXPERIMENT NO. 4
OBJECTIVE: SOLVING SYSTEM OF NON-LINEAR EQUATIONS
METHOD USED: FSOLVE
PROCEDURE
EXPERIMENT NO. 5
% we put m = f(Cr)
In the command we can use function ode23 or ode 45. The only difference is in the results,
which are more accurate in the latter because in involves more rigorous calculation. The
function, say ode45, is used as follows
>> [ t Cr ] = ode45 ( @myode1, [ 0 : 60 ], 0.8 ) ;
>> c = [ t Cr ] ;
>> plot ( t, Cr )
>> xlabel ( Time in minutes )
>> ylabel ( Concentration in mol/L )
>> grid
The vector [ 0 : 60 ] denotes set of time values at which Cr is calculated. 0.8 is the initial
value of Cr. The values of t an Cr are returned in vector c.
RESULT:
c=
0
0.8000
1.0000
0.4073
2.0000
0.4002
3.0000
0.4000
4.0000
0.3998
5.0000
0.4000
6.0000
0.4000
7.0000
0.4000
8.0000
0.3999
9.0000
0.3999
10.0000
0.4000
11.0000
0.4000
12.0000
0.4001
13.0000
0.4001
14.0000
0.4000
15.0000
0.4000
16.0000
0.4001
17.0000
0.4003
18.0000
0.4001
19.0000
0.4000
20.0000
0.4001
21.0000
0.4002
22.0000
0.4004
23.0000
0.4001
24.0000
0.4000
8
25.0000
0.4001
26.0000
0.4003
27.0000
0.4004
28.0000
0.4000
29.0000
0.4000
30.0000
0.4001
31.0000
0.4004
32.0000
0.4002
33.0000
0.4000
34.0000
0.4000
35.0000
0.4001
36.0000
0.4001
37.0000
0.3999
38.0000
0.3997
39.0000
0.4000
40.0000
0.4001
41.0000
0.4000
42.0000
0.4000
43.0000
0.4000
44.0000
0.4000
45.0000
0.4000
46.0000
0.4001
47.0000
0.4002
48.0000
0.4000
49.0000
0.4000
50.0000
0.4001
51.0000
0.4003
9
52.0000
0.4000
53.0000
0.4000
54.0000
0.4000
55.0000
0.4002
56.0000
0.4002
57.0000
0.4000
58.0000
0.3999
59.0000
0.3998
60.0000
0.4001
0.8
0.75
Concentration in mol/L
0.7
0.65
0.6
0.55
0.5
0.45
0.4
0.35
10
20
30
Time in minutes
40
50
60
PRECAUTIONS:
10
EXPERIMENT NO. 6
11
1.0000
1.0000
0.9048
0.0905
0.0047
2.0000
0.8187
0.1637
0.0175
3.0000
0.7408
0.2223
0.0369
4.0000
0.6703
0.2681
0.0615
5.0000
0.6065
0.3033
0.0902
6.0000
0.5488
0.3293
0.1219
7.0000
0.4966
0.3477
0.1558
8.0000
0.4493
0.3596
0.1911
9.0000
0.4065
0.3661
0.2274
10.0000
0.3678
0.3681
0.2641
11.0000
0.3328
0.3664
0.3008
12.0000
0.3011
0.3617
0.3372
13.0000
0.2724
0.3546
0.3730
14.0000
0.2465
0.3456
0.4080
15.0000
0.2230
0.3351
0.4419
16.0000
0.2018
0.3234
0.4749
17.0000
0.1825
0.3110
0.5065
18.0000
0.1651
0.2980
0.5369
19.0000
0.1494
0.2846
0.5660
12
20.0000
0.1351
0.2711
0.5938
21.0000
0.1222
0.2576
0.6202
22.0000
0.1106
0.2442
0.6452
23.0000
0.1001
0.2310
0.6690
24.0000
0.0905
0.2181
0.6914
25.0000
0.0819
0.2056
0.7126
26.0000
0.0741
0.1934
0.7325
27.0000
0.0670
0.1817
0.7512
28.0000
0.0606
0.1705
0.7688
29.0000
0.0548
0.1598
0.7853
30.0000
0.0496
0.1496
0.8008
31.0000
0.0449
0.1398
0.8153
32.0000
0.0406
0.1306
0.8288
33.0000
0.0367
0.1219
0.8414
34.0000
0.0332
0.1136
0.8532
35.0000 0.0301
0.1058
0.8641
36.0000
0.0272
0.0984
0.8744
37.0000
0.0246
0.0915
0.8839
38.0000
0.0223
0.0851
0.8927
39.0000
0.0201
0.0790
0.9009
40.0000
0.0182
0.0733
0.9085
41.0000
0.0165 0.0680
0.9156
42.0000
0.0149
0.0630
0.9221
43.0000
0.0135
0.0583
0.9282
44.0000
0.0122
0.0540
0.9338
45.0000
0.0110
0.0500
0.9390
46.0000
0.0100
0.0462
0.9438
13
47.0000
0.0090
0.0427
0.9482
48.0000
0.0082
0.0395
0.9524
49.0000
0.0074
0.0365
0.9562
50.0000
0.0067
0.0337
0.9597
51.0000
0.0060
0.0311
0.9629
52.0000
0.0055
0.0286
0.9659
53.0000
0.0050
0.0264
0.9686
54.0000
0.0045
0.0243
0.9712
55.0000
0.0041
0.0224
0.9735
56.0000
0.0037
0.0207
0.9757
57.0000
0.0033
0.0190
0.9777
58.0000
0.0030
0.0175
0.9795
59.0000
0.0027
0.0161
0.9812
60.0000
0.0025
0.0148
0.9827
1
CA
CR
CS
0.9
Concentration in mol/L
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
10
20
30
Time in minutes
40
50
60
PRECAUTIONS:
EXPERIMENT NO. 7
OBJECTIVE : SOLVING PARTIAL DIFFERENTIAL EQUATION
METHOD USED: PDEPE
PROCEDURE:
Q. Solve the unsteady state heat equation in one dimension
with = 0.1 m2/s, initial conditions T( x, 0 ) = 20K and boundary conditions T( 0, t ) = 300K
& T( 0.8, t ) = 300K.
PDEs like above can be solved using function pdepe. In standard form
m and
s, we make a
15
>> m = 0 ;
>> x = 0 : 0.1 : 0.8 ;
>> t = 0 : 0.1 : 3.1 ;
>> sol = pdepe ( m , @pdex1pde , @pdex1ic , @pdex1bc , x , t ) ;
>> T = sol ( : , : , 1 )
>> surf ( x , t , T ) ;
>> title ( ' Temperature variation across the slab ' )
>> xlabel ( ' Distance in metres ' )
>> ylabel ( ' Time in seconds ' )
>> zlabel ( ' Temperature in Kelvin ' )
The value of temperatures are returned to the vector T, which is then plotted against distance
and time using the function surf, that generates 3 dimensional plots.
RESULT:
T=
300.0000 20.0000 20.0000 20.0000 20.0000 20.0000 20.0000 20.0000 300.0000
300.0000 153.3150 67.0590 33.3088 25.6091 33.3088 67.0590 153.3150 300.0000
300.0000 192.2620 110.3364 63.6943 49.1658 63.6943 110.3364 192.2620 300.0000
300.0000 212.2822 140.5572 95.0830 79.7108 95.0830 140.5572 212.2822 300.0000
300.0000 226.0163 164.0938 123.4612 109.3755 123.4612 164.0938 226.0163 300.0000
300.0000 236.8782 183.5989 148.2195 135.8507 148.2195 183.5989 236.8782 300.0000
300.0000 245.9018 200.1181 169.6028 158.9065 169.6028 200.1181 245.9018 300.0000
300.0000 253.5611 214.2351 187.9987 178.7958 187.9987 214.2351 253.5611 300.0000
300.0000 260.1325 226.3538 203.8010 195.8857 203.8010 226.3538 260.1325 300.0000
300.0000 265.7741 236.7605 217.3755 210.5687 217.3755 236.7605 265.7741 300.0000
300.0000 270.6107 245.6919 229.0384 223.1897 229.0384 245.6919 270.6107 300.0000
300.0000 274.7518 253.3447 239.0386 234.0145 239.0386 253.3447 274.7518 300.0000
300.0000 278.2993 259.9014 247.6077 243.2906 247.6077 259.9014 278.2993 300.0000
300.0000 281.3501 265.5407 254.9784 251.2697 254.9784 265.5407 281.3501 300.0000
300.0000 283.9619 270.3680 261.2871 258.0989 261.2871 270.3680 283.9619 300.0000
16
300
Temperature in Kelvin
250
200
150
100
50
0
4
Time in seconds
0.2
0.4
0.6
0.8
Distance in metres
PRECAUTIONS: