sExact=.5*g*3.5^2
sExact =
60.0862
sOde45=sValues(end)
sOde45 =
60.0863
format long
sExact=.5*g*3.5^2
sExact =
60.086250000000000
sOde45=sValues(end)
sOde45 =
60.086250000000007
Gallileo(0,[0 30]',0.05)
ans =
30.000000000000000
9.283998091603054
[tValues,unknownsValues]=ode45(@(t,unks) Gallileo(t,unks,r),tDesired,unknownsInitialValues)
{Undefined function or variable 'r'.
Error in @(t,unks)Gallileo(t,unks,r)
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0,
options, varargin);}
r=0.2
r =
0.200000000000000
[tValues,unknownsValues]=ode45(@(t,unks) Gallileo(t,unks,r),tDesired,unknownsInitialValues)
tValues =
0
0.071428571428571
0.142857142857143
0.214285714285714
0.285714285714286
0.357142857142857
0.428571428571429
0.500000000000000
0.571428571428571
0.642857142857143
0.714285714285714
0.785714285714286
0.857142857142857
0.928571428571429
1.000000000000000
1.071428571428571
1.142857142857143
1.214285714285714
1.285714285714286
1.357142857142857
1.428571428571429
1.500000000000000
1.571428571428571
1.642857142857143
1.714285714285714
1.785714285714286
1.857142857142857
1.928571428571429
2.000000000000000
2.071428571428572
2.142857142857143
2.214285714285714
2.285714285714286
2.357142857142857
2.428571428571428
2.500000000000000
2.571428571428572
2.642857142857143
2.714285714285714
2.785714285714286
2.857142857142857
2.928571428571428
3.000000000000000
3.071428571428572
3.142857142857143
3.214285714285714
3.285714285714286
3.357142857142857
3.428571428571428
3.500000000000000
unknownsValues =
0 0
0.025025479702061 0.700712577602831
0.100101552806205 1.401414906731393
0.225227121231892 2.102096739271069
0.400400354969772 2.802747828466737
0.625618692224924 3.503357929588811
0.900878839449648 4.203916800019729
1.226176771590266 4.904414200169339
1.601507732161968 5.604839893829435
2.026866233940558 6.305183649414062
2.502246059066925 7.005435240174135
3.027640259153556 7.705584444348730
3.603041155964383 8.405621046292710
4.228440341629103 9.105534836765113
4.903828679715163 9.805315614123433
5.629196305353159 10.504953184479341
6.404532625469886 11.204437361919389
7.229826319856802 11.903757969622889
8.105065341556095 12.602904840172926
9.030236918276552 13.301867816704000
10.005327552505179 14.000636752999039
11.030323021938361 14.699201513793847
12.105208380891847 15.397551975848097
13.229967960914836 16.095678028310381
14.404585372477197 16.793569573787170
15.629043505049413 17.491216528396002
16.903324527822953 18.188608822168547
18.227409891370687 18.885736400034713
19.601280328581140 19.582589222273729
21.024915856517474 20.279157265475458
22.498295776460580 20.975430522563514
24.021398675031840 21.671399003312217
25.594202425960773 22.367052735200595
27.216684191473853 23.062381763983296
28.888820424198833 23.757376154517530
30.610586867177567 24.452025990768796
32.381958555529046 25.146321376457241
34.202909818119807 25.840252435735298
36.073414279592541 26.533809313914539
37.993444862161155 27.226982178133234
39.962973785626637 27.919761217361575
41.981972569667484 28.612136643167130
44.050412035293675 29.304098690218627
46.168262307604977 29.995637617156106
48.335492817369364 30.686743707101016
50.552072301082212 31.377407267673291
52.817968803735567 32.067618631796485
55.133149680839090 32.757368158291534
57.497581600909534 33.446646232576917
59.911230546465873 34.135443266952095
sExact
sExact =
60.086250000000000
sValues40=unknownsValues(:,1)
sValues40 =
0
0.025025479702061
0.100101552806205
0.225227121231892
0.400400354969772
0.625618692224924
0.900878839449648
1.226176771590266
1.601507732161968
2.026866233940558
2.502246059066925
3.027640259153556
3.603041155964383
4.228440341629103
4.903828679715163
5.629196305353159
6.404532625469886
7.229826319856802
8.105065341556095
9.030236918276552
10.005327552505179
11.030323021938361
12.105208380891847
13.229967960914836
14.404585372477197
15.629043505049413
16.903324527822953
18.227409891370687
19.601280328581140
21.024915856517474
22.498295776460580
24.021398675031840
25.594202425960773
27.216684191473853
28.888820424198833
30.610586867177567
32.381958555529046
34.202909818119807
36.073414279592541
37.993444862161155
39.962973785626637
41.981972569667484
44.050412035293675
46.168262307604977
48.335492817369364
50.552072301082212
52.817968803735567
55.133149680839090
57.497581600909534
59.911230546465873
sValues40=unknownsValues(:,1);
r=0.10
r =
0.100000000000000
[tValues,unknownsValues]=ode45(@(t,unks) Gallileo(t,unks,r),tDesired,unknownsInitialValues);
sValues20=unknownsValues(:,1);
sValues20(end)
ans =
59.737831761122116
r=0.05
r =
0.050000000000000
[tValues,unknownsValues]=ode45(@(t,unks) Gallileo(t,unks,r),tDesired,unknownsInitialValues);
sValues10=unknownsValues(:,1);
sValues10(end)
ans =
59.395794944843324
r=0.025
r =
0.025000000000000
[tValues,unknownsValues]=ode45(@(t,unks) Gallileo(t,unks,r),tDesired,unknownsInitialValues);
sValues05=unknownsValues(:,1);
sValues06(end)
{Undefined function or variable 'sValues06'.}
sValues05(end)
ans =
58.730086344617256
r=0.01
r =
0.010000000000000
[tValues,unknownsValues]=ode45(@(t,unks) Gallileo(t,unks,r),tDesired,unknownsInitialValues);
sValues02=unknownsValues(:,1);
r=0.005
r =
0.005000000000000
[tValues,unknownsValues]=ode45(@(t,unks) Gallileo(t,unks,r),tDesired,unknownsInitialValues);
sValues01=unknownsValues(:,1);
sValues02(end)
ans =
56.867278237908963
sValues01(end)
ans =
54.140914300876460
tv=tValues
tv =
0
0.071428571428571
0.142857142857143
0.214285714285714
0.285714285714286
0.357142857142857
0.428571428571429
0.500000000000000
0.571428571428571
0.642857142857143
0.714285714285714
0.785714285714286
0.857142857142857
0.928571428571429
1.000000000000000
1.071428571428571
1.142857142857143
1.214285714285714
1.285714285714286
1.357142857142857
1.428571428571429
1.500000000000000
1.571428571428571
1.642857142857143
1.714285714285714
1.785714285714286
1.857142857142857
1.928571428571429
2.000000000000000
2.071428571428572
2.142857142857143
2.214285714285714
2.285714285714286
2.357142857142857
2.428571428571428
2.500000000000000
2.571428571428572
2.642857142857143
2.714285714285714
2.785714285714286
2.857142857142857
2.928571428571428
3.000000000000000
3.071428571428572
3.142857142857143
3.214285714285714
3.285714285714286
3.357142857142857
3.428571428571428
3.500000000000000
plot(tv,sValues40,tv,sValues20,tv,sValues10,tv,sValues05,tv,sValues02.tv,sValues01)
{Dot indexing is not supported for variables of this type.}
plot(tv,sValues40,tv,sValues20,tv,sValues10,tv,sValues05,tv,sValues02,tv,sValues01)