% Part B
clc; clear all; close all;
A = 2 ;
t1 = 0.1 ;
delta_h = 0 ;
h = 0.1 ;
z = 2 ;
Kc = 1:1:5 ;
N = length(Kc) ;
x = zeros(N,[]) ;
y = zeros(N,[]) ;
for i = 1:length(Kc)
count = 0 ;
f = (Kc(i)/A)*z+((Kc(i)/(A*t1)*delta_h));
for t = 0:h:10
count = count+1 ;
delta_h_next = delta_h + (z * h) ;
z_next = z - (f * h) ;
delta_h = delta_h_next ;
z = z_next ;
fprintf('%5.4f %11.8f \n', t, delta_h);
x(i,count) = t ;
y(i,count) = delta_h ;
end
end
0.0000 0.20000000
0.1000 0.39000000
0.2000 0.57000000
0.3000 0.74000000
0.4000 0.90000000
0.5000 1.05000000
0.6000 1.19000000
0.7000 1.32000000
0.8000 1.44000000
0.9000 1.55000000
1.0000 1.65000000
1.1000 1.74000000
1.2000 1.82000000
1.3000 1.89000000
1.4000 1.95000000
1.5000 2.00000000
1.6000 2.04000000
1.7000 2.07000000
1.8000 2.09000000
1.9000 2.10000000
2.0000 2.10000000
2.1000 2.09000000
2.2000 2.07000000
2.3000 2.04000000
2.4000 2.00000000
2.5000 1.95000000
2.6000 1.89000000
2.7000 1.82000000
2.8000 1.74000000
2.9000 1.65000000
3.0000 1.55000000
3.1000 1.44000000
3.2000 1.32000000
3.3000 1.19000000
3.4000 1.05000000
3.5000 0.90000000
3.6000 0.74000000
3.7000 0.57000000
3.8000 0.39000000
3.9000 0.20000000
4.0000 -0.00000000
4.1000 -0.21000000
4.2000 -0.43000000
4.3000 -0.66000000
4.4000 -0.90000000
4.5000 -1.15000000
4.6000 -1.41000000
4.7000 -1.68000000
4.8000 -1.96000000
4.9000 -2.25000000
5.0000 -2.55000000
5.1000 -2.86000000
5.2000 -3.18000000
5.3000 -3.51000000
5.4000 -3.85000000
5.5000 -4.20000000
5.6000 -4.56000000
5.7000 -4.93000000
5.8000 -5.31000000
5.9000 -5.70000000
6.0000 -6.10000000
6.1000 -6.51000000
6.2000 -6.93000000
6.3000 -7.36000000
6.4000 -7.80000000
6.5000 -8.25000000
6.6000 -8.71000000
6.7000 -9.18000000
6.8000 -9.66000000
6.9000 -10.15000000
7.0000 -10.65000000
7.1000 -11.16000000
7.2000 -11.68000000
7.3000 -12.21000000
7.4000 -12.75000000
7.5000 -13.30000000
7.6000 -13.86000000
7.7000 -14.43000000
7.8000 -15.01000000
7.9000 -15.60000000
8.0000 -16.20000000
8.1000 -16.81000000
8.2000 -17.43000000
8.3000 -18.06000000
8.4000 -18.70000000
8.5000 -19.35000000
8.6000 -20.01000000
8.7000 -20.68000000
8.8000 -21.36000000
8.9000 -22.05000000
9.0000 -22.75000000
9.1000 -23.46000000
9.2000 -24.18000000
9.3000 -24.91000000
9.4000 -25.65000000
9.5000 -26.40000000
9.6000 -27.16000000
9.7000 -27.93000000
9.8000 -28.71000000
9.9000 -29.50000000
10.0000 -30.30000000
0.0000 -31.11000000
0.1000 -28.80900000
0.2000 -23.39700000
0.3000 -14.87400000
0.4000 -3.24000000
0.5000 11.50500000
0.6000 29.36100000
0.7000 50.32800000
0.8000 74.40600000
0.9000 101.59500000
1.0000 131.89500000
1.1000 165.30600000
1.2000 201.82800000
1.3000 241.46100000
1.4000 284.20500000
1.5000 330.06000000
1.6000 379.02600000
1.7000 431.10300000
1.8000 486.29100000
1.9000 544.59000000
2.0000 606.00000000
2.1000 670.52100000
2.2000 738.15300000
2.3000 808.89600000
2.4000 882.75000000
2.5000 959.71500000
2.6000 1039.79100000
2.7000 1122.97800000
2.8000 1209.27600000
2.9000 1298.68500000
3.0000 1391.20500000
3.1000 1486.83600000
3.2000 1585.57800000
3.3000 1687.43100000
3.4000 1792.39500000
3.5000 1900.47000000
3.6000 2011.65600000
3.7000 2125.95300000
3.8000 2243.36100000
3.9000 2363.88000000
4.0000 2487.51000000
4.1000 2614.25100000
4.2000 2744.10300000
4.3000 2877.06600000
4.4000 3013.14000000
4.5000 3152.32500000
4.6000 3294.62100000
4.7000 3440.02800000
4.8000 3588.54600000
4.9000 3740.17500000
5.0000 3894.91500000
5.1000 4052.76600000
5.2000 4213.72800000
5.3000 4377.80100000
5.4000 4544.98500000
5.5000 4715.28000000
5.6000 4888.68600000
5.7000 5065.20300000
5.8000 5244.83100000
5.9000 5427.57000000
6.0000 5613.42000000
6.1000 5802.38100000
6.2000 5994.45300000
6.3000 6189.63600000
6.4000 6387.93000000
6.5000 6589.33500000
6.6000 6793.85100000
6.7000 7001.47800000
6.8000 7212.21600000
6.9000 7426.06500000
7.0000 7643.02500000
7.1000 7863.09600000
7.2000 8086.27800000
7.3000 8312.57100000
7.4000 8541.97500000
7.5000 8774.49000000
7.6000 9010.11600000
7.7000 9248.85300000
7.8000 9490.70100000
7.9000 9735.66000000
8.0000 9983.73000000
8.1000 10234.91100000
8.2000 10489.20300000
8.3000 10746.60600000
8.4000 11007.12000000
8.5000 11270.74500000
8.6000 11537.48100000
8.7000 11807.32800000
8.8000 12080.28600000
8.9000 12356.35500000
9.0000 12635.53500000
9.1000 12917.82600000
9.2000 13203.22800000
9.3000 13491.74100000
9.4000 13783.36500000
9.5000 14078.10000000
9.6000 14375.94600000
9.7000 14676.90300000
9.8000 14980.97100000
9.9000 15288.15000000
10.0000 15598.44000000
0.0000 15911.84100000
0.1000 13838.46585000
0.2000 9378.31455000
0.3000 2531.38710000
0.4000 -6702.31650000
0.5000 -18322.79625000
0.6000 -32330.05215000
0.7000 -48724.08420000
0.8000 -67504.89240000
0.9000 -88672.47675000
1.0000 -112226.83725000
1.1000 -138167.97390000
1.2000 -166495.88670000
1.3000 -197210.57565000
1.4000 -230312.04075000
1.5000 -265800.28200000
1.6000 -303675.29940000
1.7000 -343937.09295000
1.8000 -386585.66265000
1.9000 -431621.00850000
2.0000 -479043.13050000
2.1000 -528852.02865000
2.2000 -581047.70295000
2.3000 -635630.15340000
2.4000 -692599.38000000
2.5000 -751955.38275000
2.6000 -813698.16165000
2.7000 -877827.71670000
2.8000 -944344.04790000
2.9000 -1013247.15525000
3.0000 -1084537.03875000
3.1000 -1158213.69840000
3.2000 -1234277.13420000
3.3000 -1312727.34615000
3.4000 -1393564.33425000
3.5000 -1476788.09850000
3.6000 -1562398.63890000
3.7000 -1650395.95545000
3.8000 -1740780.04815000
3.9000 -1833550.91700000
4.0000 -1928708.56200000
4.1000 -2026252.98315000
4.2000 -2126184.18045000
4.3000 -2228502.15390000
4.4000 -2333206.90350000
4.5000 -2440298.42925000
4.6000 -2549776.73115000
4.7000 -2661641.80920000
4.8000 -2775893.66340000
4.9000 -2892532.29375000
5.0000 -3011557.70025000
5.1000 -3132969.88290000
5.2000 -3256768.84170000
5.3000 -3382954.57665000
5.4000 -3511527.08775000
5.5000 -3642486.37500000
5.6000 -3775832.43840000
5.7000 -3911565.27795000
5.8000 -4049684.89365000
5.9000 -4190191.28550000
6.0000 -4333084.45350000
6.1000 -4478364.39765000
6.2000 -4626031.11795000
6.3000 -4776084.61440000
6.4000 -4928524.88700000
6.5000 -5083351.93575000
6.6000 -5240565.76065000
6.7000 -5400166.36170000
6.8000 -5562153.73890000
6.9000 -5726527.89225000
7.0000 -5893288.82175000
7.1000 -6062436.52740000
7.2000 -6233971.00920000
7.3000 -6407892.26715000
7.4000 -6584200.30125000
7.5000 -6762895.11150000
7.6000 -6943976.69790000
7.7000 -7127445.06045000
7.8000 -7313300.19915000
7.9000 -7501542.11400000
8.0000 -7692170.80500000
8.1000 -7885186.27215000
8.2000 -8080588.51545000
8.3000 -8278377.53490000
8.4000 -8478553.33050000
8.5000 -8681115.90225000
8.6000 -8886065.25015000
8.7000 -9093401.37420001
8.8000 -9303124.27440001
8.9000 -9515233.95075000
9.0000 -9729730.40325001
9.1000 -9946613.63190001
9.2000 -10165883.63670000
9.3000 -10387540.41765000
9.4000 -10611583.97475000
9.5000 -10838014.30800001
9.6000 -11066831.41740001
9.7000 -11298035.30295001
9.8000 -11531625.96465001
9.9000 -11767603.40250001
10.0000 -12005967.61650001
0.0000 -12246718.60665001
0.1000 -10038125.87547001
0.2000 -5380189.42296000
0.3000 1727090.75088000
0.4000 11283714.64605001
0.5000 23289682.26255002
0.6000 37744993.60038003
0.7000 54649648.65954004
0.8000 74003647.44003005
0.9000 95806989.94185007
1.0000 120059676.16500008
1.1000 146761706.10948011
1.2000 175913079.77529013
1.3000 207513797.16243017
1.4000 241563858.27090019
1.5000 278063263.10070020
1.6000 317012011.65183020
1.7000 358410103.92429018
1.8000 402257539.91808021
1.9000 448554319.63320023
2.0000 497300443.06965023
2.1000 548495910.22743022
2.2000 602140721.10654020
2.3000 658234875.70698023
2.4000 716778374.02875018
2.5000 777771216.07185018
2.6000 841213401.83628023
2.7000 907104931.32204020
2.8000 975445804.52913022
2.9000 1046236021.45755029
3.0000 1119475582.10730028
3.1000 1195164486.47838020
3.2000 1273302734.57079029
3.3000 1353890326.38453031
3.4000 1436927261.91960025
3.5000 1522413541.17600036
3.6000 1610349164.15373039
3.7000 1700734130.85279036
3.8000 1793568441.27318048
3.9000 1888852095.41490054
4.0000 1986585093.27795053
4.1000 2086767434.86233044
4.2000 2189399120.16804028
4.3000 2294480149.19508028
4.4000 2402010521.94345045
4.5000 2511990238.41315031
4.6000 2624419298.60418034
4.7000 2739297702.51654053
4.8000 2856625450.15023041
4.9000 2976402541.50525045
5.0000 3098628976.58160067
5.1000 3223304755.37928057
5.2000 3350429877.89829063
5.3000 3480004344.13863087
5.4000 3612028154.10030079
5.5000 3746501307.78330088
5.6000 3883423805.18763065
5.7000 4022795646.31329060
5.8000 4164616831.16028070
5.9000 4308887359.72860050
6.0000 4455607232.01825047
6.1000 4604776448.02923012
6.2000 4756395007.76154041
6.3000 4910462911.21518040
6.4000 5066980158.39015007
6.5000 5225946749.28645039
6.6000 5387362683.90408039
6.7000 5551227962.24304008
6.8000 5717542584.30333042
6.9000 5886306550.08495045
7.0000 6057519859.58790016
7.1000 6231182512.81218052
7.2000 6407294509.75779057
7.3000 6585855850.42473030
7.4000 6766866534.81300068
7.5000 6950326562.92260075
7.6000 7136235934.75353050
7.7000 7324594650.30579090
7.8000 7515402709.57938099
7.9000 7708660112.57430077
8.0000 7904366859.29055119
8.1000 8102522949.72813129
8.2000 8303128383.88704109
8.3000 8506183161.76728058
8.4000 8711687283.36885071
8.5000 8919640748.69175148
8.6000 9130043557.73598099
8.7000 9342895710.50154114
8.8000 9558197206.98843193
8.9000 9775948047.19665146
9.0000 9996148231.12620163
9.1000 10218797758.77708244
9.2000 10443896630.14929199
9.3000 10671444845.24283218
9.4000 10901442404.05770302
9.5000 11133889306.59390259
9.6000 11368785552.85143280
9.7000 11606131142.83029366
9.8000 11845926076.53048325
9.9000 12088170353.95200348
10.0000 12332863975.09485435
0.0000 12580006939.95903397
0.1000 9682148169.83345604
0.2000 3639287664.71811867
0.3000 -5548574575.38697624
0.4000 -17881438550.48183060
0.5000 -33359304260.56644440
0.6000 -51982171705.64081573
0.7000 -73750040885.70495605
0.8000 -98662911800.75885010
0.9000 -126720784450.80249023
1.0000 -157923658835.83590698
1.1000 -192271534955.85906982
1.2000 -229764412810.87200928
1.3000 -270402292400.87469482
1.4000 -314185173725.86712646
1.5000 -361113056785.84930420
1.6000 -411185941580.82128906
1.7000 -464403828110.78302002
1.8000 -520766716375.73449707
1.9000 -580274606375.67578125
2.0000 -642927498110.60681152
2.1000 -708725391580.52758789
2.2000 -777668286785.43811035
2.3000 -849756183725.33837891
2.4000 -924989082400.22839355
2.5000 -1003366982810.10815430
2.6000 -1084889884954.97766113
2.7000 -1169557788834.83691406
2.8000 -1257370694449.68603516
2.9000 -1348328601799.52490234
3.0000 -1442431510884.35351562
3.1000 -1539679421704.17187500
3.2000 -1640072334258.97998047
3.3000 -1743610248548.77783203
3.4000 -1850293164573.56542969
3.5000 -1960121082333.34277344
3.6000 -2073094001828.10986328
3.7000 -2189211923057.86669922
3.8000 -2308474846022.61328125
3.9000 -2430882770722.34960938
4.0000 -2556435697157.07568359
4.1000 -2685133625326.79150391
4.2000 -2816976555231.49707031
4.3000 -2951964486871.19238281
4.4000 -3090097420245.87744141
4.5000 -3231375355355.55224609
4.6000 -3375798292200.21679688
4.7000 -3523366230779.87109375
4.8000 -3674079171094.51513672
4.9000 -3827937113144.14892578
5.0000 -3984940056928.77246094
5.1000 -4145088002448.38574219
5.2000 -4308380949702.98876953
5.3000 -4474818898692.58203125
5.4000 -4644401849417.16503906
5.5000 -4817129801876.73730469
5.6000 -4993002756071.29980469
5.7000 -5172020712000.85156250
5.8000 -5354183669665.39355469
5.9000 -5539491629064.92480469
6.0000 -5727944590199.44628906
6.1000 -5919542553068.95703125
6.2000 -6114285517673.45800781
6.3000 -6312173484012.94824219
6.4000 -6513206452087.42871094
6.5000 -6717384421896.89843750
6.6000 -6924707393441.35839844
6.7000 -7135175366720.80761719
6.8000 -7348788341735.24707031
6.9000 -7565546318484.67578125
7.0000 -7785449296969.09472656
7.1000 -8008497277188.50292969
7.2000 -8234690259142.90136719
7.3000 -8464028242832.28906250
7.4000 -8696511228256.66699219
7.5000 -8932139215416.03515625
7.6000 -9170912204310.39257812
7.7000 -9412830194939.74023438
7.8000 -9657893187304.07617188
7.9000 -9906101181403.40234375
8.0000 -10157454177237.71875000
8.1000 -10411952174807.02539062
8.2000 -10669595174111.32031250
8.3000 -10930383175150.60546875
8.4000 -11194316177924.88085938
8.5000 -11461394182434.14648438
8.6000 -11731617188678.40039062
8.7000 -12004985196657.64453125
8.8000 -12281498206371.87890625
8.9000 -12561156217821.10351562
9.0000 -12843959231005.31640625
9.1000 -13129907245924.51953125
9.2000 -13419000262578.71289062
9.3000 -13711238280967.89648438
9.4000 -14006621301092.06835938
9.5000 -14305149322951.23046875
9.6000 -14606822346545.38281250
9.7000 -14911640371874.52539062
9.8000 -15219603398938.65625000
9.9000 -15530711427737.77734375
10.0000 -15844964458271.88867188
plot(x',y')