time=[0 0.5 1 1.5 2] time = 0 0.5000 1.0000 1.5000 2.0000 time=[0 0.5 1 1.5 2]; timeMeasured=[0 0.5 1 1.5 2]; TempMeasured=[14.6 8.42 4.86 2.8 1.62]; plot(timeMeasured,TempMeasured) plot(timeMeasured,TempMeasured,'o') time=0.7 time = 0.7000 TempLinear=interp1(timeMeasured,TempMeasured) TempLinear = NaN NaN 1.9300 0.9000 0.3100 TempLinear=interp1(timeMeasured,TempMeasured,time) TempLinear = 6.9960 TempSpline=spline(timeMeasured,TempMeasured,time) TempSpline = 6.7513 TempMeasuredFun = @(time) 14.6*exp(-1.1*time); TempMeasuredFun(0) ans = 14.6000 TempMeasuredFun(0.5) ans = 8.4235 TempMeasuredFun(0.7) ans = 6.7600 timePlot=linspace(0,2,100); timePlot=linspace(0,2,100) timePlot = Columns 1 through 7 0 0.0202 0.0404 0.0606 0.0808 0.1010 0.1212 Columns 8 through 14 0.1414 0.1616 0.1818 0.2020 0.2222 0.2424 0.2626 Columns 15 through 21 0.2828 0.3030 0.3232 0.3434 0.3636 0.3838 0.4040 Columns 22 through 28 0.4242 0.4444 0.4646 0.4848 0.5051 0.5253 0.5455 Columns 29 through 35 0.5657 0.5859 0.6061 0.6263 0.6465 0.6667 0.6869 Columns 36 through 42 0.7071 0.7273 0.7475 0.7677 0.7879 0.8081 0.8283 Columns 43 through 49 0.8485 0.8687 0.8889 0.9091 0.9293 0.9495 0.9697 Columns 50 through 56 0.9899 1.0101 1.0303 1.0505 1.0707 1.0909 1.1111 Columns 57 through 63 1.1313 1.1515 1.1717 1.1919 1.2121 1.2323 1.2525 Columns 64 through 70 1.2727 1.2929 1.3131 1.3333 1.3535 1.3737 1.3939 Columns 71 through 77 1.4141 1.4343 1.4545 1.4747 1.4949 1.5152 1.5354 Columns 78 through 84 1.5556 1.5758 1.5960 1.6162 1.6364 1.6566 1.6768 Columns 85 through 91 1.6970 1.7172 1.7374 1.7576 1.7778 1.7980 1.8182 Columns 92 through 98 1.8384 1.8586 1.8788 1.8990 1.9192 1.9394 1.9596 Columns 99 through 100 1.9798 2.0000 timePlot=linspace(0,2,100); TempExactPlot=TempExactFun(timePlot) {Undefined function or variable 'TempExactFun'.} clear TempMeasuredFun TempExactFun = @(time) 14.6*exp(-1.1*time); TempExactPlot=TempExactFun(timePlot); TempExactPlot TempExactPlot = Columns 1 through 7 14.6000 14.2791 13.9653 13.6584 13.3582 13.0647 12.7775 Columns 8 through 14 12.4967 12.2221 11.9535 11.6908 11.4338 11.1826 10.9368 Columns 15 through 21 10.6964 10.4614 10.2314 10.0066 9.7867 9.5716 9.3612 Columns 22 through 28 9.1555 8.9543 8.7575 8.5650 8.3768 8.1927 8.0126 Columns 29 through 35 7.8366 7.6643 7.4959 7.3312 7.1700 7.0125 6.8583 Columns 36 through 42 6.7076 6.5602 6.4160 6.2750 6.1371 6.0022 5.8703 Columns 43 through 49 5.7413 5.6151 5.4917 5.3710 5.2530 5.1376 5.0246 Columns 50 through 56 4.9142 4.8062 4.7006 4.5973 4.4963 4.3974 4.3008 Columns 57 through 63 4.2063 4.1138 4.0234 3.9350 3.8485 3.7639 3.6812 Columns 64 through 70 3.6003 3.5212 3.4438 3.3681 3.2941 3.2217 3.1509 Columns 71 through 77 3.0817 3.0139 2.9477 2.8829 2.8195 2.7576 2.6970 Columns 78 through 84 2.6377 2.5797 2.5230 2.4676 2.4134 2.3603 2.3085 Columns 85 through 91 2.2577 2.2081 2.1596 2.1121 2.0657 2.0203 1.9759 Columns 92 through 98 1.9325 1.8900 1.8485 1.8078 1.7681 1.7293 1.6912 Columns 99 through 100 1.6541 1.6177 plot(timePlot,TempExactPlot,'--') plot(timePlot,TempExactPlot,'--k') clear TempMeasuredFun; TempExactFun = @(time) 14.6*exp(-1.1*time); TempExactPlot=TempExactFun(timePlot); timePlot=linspace(0,2,100); TempLinearPlot=interp1(timeMeasured,TempMeasured,timePlot); TempSplinePlot=spline(timeMeasured,TempMeasured,timePlot); plot(timePlot,TempExactPlot,'--k',timeMeasured,TempMeasured,'o',timePlot,TempLinearPlot,'r',timePlot,TempSplinePlot,'b') plot(timePlot,TempExactPlot,'--k',timeMeasured,TempMeasured,'o',...timePlot,TempLinearPlot,'r',timePlot,TempSplinePlot,'b') plot(timePlot,TempExactPlot,'--k',timeMeasured,TempMeasured,'o',... timePlot,TempLinearPlot,'r',timePlot,TempSplinePlot,'b') timePlot,TempLinearPlot,'r',timePlot,TempSplinePlot,'b')  {Error: Expression or statement is incorrect--possibly unbalanced (, {, or [. } plot(timePlot,TempExactPlot,'--k',timeMeasured,TempMeasured,'o',... timePlot,TempLinearPlot,'r',timePlot,TempSplinePlot,'b') time=5 time = 5 TempExactFun(time) ans = 0.0597 TempLinear=interp1(timeMeasured,TempMeasured,time) TempLinear = NaN TempLinear=interp1(timeMeasured,TempMeasured,time,'linear','extrap') TempLinear = -5.4600 TempSpline=spline(timeMeasured,TempMeasured,time) TempSpline = -14.7000 TempMeasured TempMeasured = 14.6000 8.4200 4.8600 2.8000 1.6200 TempMeasured=[15 8 5 3 2] TempMeasured = 15 8 5 3 2 TempSplinePlot=spline(timeMeasured,TempMeasured,timePlot); TempLinearPlot=interp1(timeMeasured,TempMeasured,timePlot); plot(timePlot,TempExactPlot,'--k',timeMeasured,TempMeasured,'o',... timePlot,TempLinearPlot,'r',timePlot,TempSplinePlot,'b') TempLinearPlot TempLinearPlot = Columns 1 through 7 15.0000 14.7172 14.4343 14.1515 13.8687 13.5859 13.3030 Columns 8 through 14 13.0202 12.7374 12.4545 12.1717 11.8889 11.6061 11.3232 Columns 15 through 21 11.0404 10.7576 10.4747 10.1919 9.9091 9.6263 9.3434 Columns 22 through 28 9.0606 8.7778 8.4949 8.2121 7.9697 7.8485 7.7273 Columns 29 through 35 7.6061 7.4848 7.3636 7.2424 7.1212 7.0000 6.8788 Columns 36 through 42 6.7576 6.6364 6.5152 6.3939 6.2727 6.1515 6.0303 Columns 43 through 49 5.9091 5.7879 5.6667 5.5455 5.4242 5.3030 5.1818 Columns 50 through 56 5.0606 4.9596 4.8788 4.7980 4.7172 4.6364 4.5556 Columns 57 through 63 4.4747 4.3939 4.3131 4.2323 4.1515 4.0707 3.9899 Columns 64 through 70 3.9091 3.8283 3.7475 3.6667 3.5859 3.5051 3.4242 Columns 71 through 77 3.3434 3.2626 3.1818 3.1010 3.0202 2.9697 2.9293 Columns 78 through 84 2.8889 2.8485 2.8081 2.7677 2.7273 2.6869 2.6465 Columns 85 through 91 2.6061 2.5657 2.5253 2.4848 2.4444 2.4040 2.3636 Columns 92 through 98 2.3232 2.2828 2.2424 2.2020 2.1616 2.1212 2.0808 Columns 99 through 100 2.0404 2.0000 TempExactPlot TempExactPlot = Columns 1 through 7 14.6000 14.2791 13.9653 13.6584 13.3582 13.0647 12.7775 Columns 8 through 14 12.4967 12.2221 11.9535 11.6908 11.4338 11.1826 10.9368 Columns 15 through 21 10.6964 10.4614 10.2314 10.0066 9.7867 9.5716 9.3612 Columns 22 through 28 9.1555 8.9543 8.7575 8.5650 8.3768 8.1927 8.0126 Columns 29 through 35 7.8366 7.6643 7.4959 7.3312 7.1700 7.0125 6.8583 Columns 36 through 42 6.7076 6.5602 6.4160 6.2750 6.1371 6.0022 5.8703 Columns 43 through 49 5.7413 5.6151 5.4917 5.3710 5.2530 5.1376 5.0246 Columns 50 through 56 4.9142 4.8062 4.7006 4.5973 4.4963 4.3974 4.3008 Columns 57 through 63 4.2063 4.1138 4.0234 3.9350 3.8485 3.7639 3.6812 Columns 64 through 70 3.6003 3.5212 3.4438 3.3681 3.2941 3.2217 3.1509 Columns 71 through 77 3.0817 3.0139 2.9477 2.8829 2.8195 2.7576 2.6970 Columns 78 through 84 2.6377 2.5797 2.5230 2.4676 2.4134 2.3603 2.3085 Columns 85 through 91 2.2577 2.2081 2.1596 2.1121 2.0657 2.0203 1.9759 Columns 92 through 98 1.9325 1.8900 1.8485 1.8078 1.7681 1.7293 1.6912 Columns 99 through 100 1.6541 1.6177 TempLinearPlot-TempExactPlot ans = Columns 1 through 7 0.4000 0.4380 0.4690 0.4931 0.5105 0.5212 0.5255 Columns 8 through 14 0.5235 0.5153 0.5011 0.4810 0.4551 0.4235 0.3864 Columns 15 through 21 0.3440 0.2962 0.2433 0.1853 0.1224 0.0547 -0.0178 Columns 22 through 28 -0.0949 -0.1765 -0.2625 -0.3529 -0.4071 -0.3442 -0.2854 Columns 29 through 35 -0.2305 -0.1795 -0.1323 -0.0887 -0.0488 -0.0125 0.0204 Columns 36 through 42 0.0500 0.0762 0.0991 0.1189 0.1356 0.1493 0.1600 Columns 43 through 49 0.1678 0.1727 0.1749 0.1744 0.1712 0.1655 0.1572 Columns 50 through 56 0.1464 0.1534 0.1782 0.2007 0.2209 0.2389 0.2548 Columns 57 through 63 0.2685 0.2801 0.2897 0.2973 0.3030 0.3068 0.3087 Columns 64 through 70 0.3088 0.3071 0.3037 0.2985 0.2918 0.2833 0.2733 Columns 71 through 77 0.2618 0.2487 0.2341 0.2181 0.2007 0.2121 0.2323 Columns 78 through 84 0.2512 0.2687 0.2850 0.3001 0.3139 0.3265 0.3380 Columns 85 through 91 0.3483 0.3576 0.3657 0.3727 0.3788 0.3837 0.3877 Columns 92 through 98 0.3908 0.3928 0.3940 0.3942 0.3935 0.3920 0.3896 Columns 99 through 100 0.3863 0.3823 abs(TempLinearPlot-TempExactPlot) ans = Columns 1 through 7 0.4000 0.4380 0.4690 0.4931 0.5105 0.5212 0.5255 Columns 8 through 14 0.5235 0.5153 0.5011 0.4810 0.4551 0.4235 0.3864 Columns 15 through 21 0.3440 0.2962 0.2433 0.1853 0.1224 0.0547 0.0178 Columns 22 through 28 0.0949 0.1765 0.2625 0.3529 0.4071 0.3442 0.2854 Columns 29 through 35 0.2305 0.1795 0.1323 0.0887 0.0488 0.0125 0.0204 Columns 36 through 42 0.0500 0.0762 0.0991 0.1189 0.1356 0.1493 0.1600 Columns 43 through 49 0.1678 0.1727 0.1749 0.1744 0.1712 0.1655 0.1572 Columns 50 through 56 0.1464 0.1534 0.1782 0.2007 0.2209 0.2389 0.2548 Columns 57 through 63 0.2685 0.2801 0.2897 0.2973 0.3030 0.3068 0.3087 Columns 64 through 70 0.3088 0.3071 0.3037 0.2985 0.2918 0.2833 0.2733 Columns 71 through 77 0.2618 0.2487 0.2341 0.2181 0.2007 0.2121 0.2323 Columns 78 through 84 0.2512 0.2687 0.2850 0.3001 0.3139 0.3265 0.3380 Columns 85 through 91 0.3483 0.3576 0.3657 0.3727 0.3788 0.3837 0.3877 Columns 92 through 98 0.3908 0.3928 0.3940 0.3942 0.3935 0.3920 0.3896 Columns 99 through 100 0.3863 0.3823 abs(TempLinearPlot-TempExactPlot) ans = Columns 1 through 7 0.4000 0.4380 0.4690 0.4931 0.5105 0.5212 0.5255 Columns 8 through 14 0.5235 0.5153 0.5011 0.4810 0.4551 0.4235 0.3864 Columns 15 through 21 0.3440 0.2962 0.2433 0.1853 0.1224 0.0547 0.0178 Columns 22 through 28 0.0949 0.1765 0.2625 0.3529 0.4071 0.3442 0.2854 Columns 29 through 35 0.2305 0.1795 0.1323 0.0887 0.0488 0.0125 0.0204 Columns 36 through 42 0.0500 0.0762 0.0991 0.1189 0.1356 0.1493 0.1600 Columns 43 through 49 0.1678 0.1727 0.1749 0.1744 0.1712 0.1655 0.1572 Columns 50 through 56 0.1464 0.1534 0.1782 0.2007 0.2209 0.2389 0.2548 Columns 57 through 63 0.2685 0.2801 0.2897 0.2973 0.3030 0.3068 0.3087 Columns 64 through 70 0.3088 0.3071 0.3037 0.2985 0.2918 0.2833 0.2733 Columns 71 through 77 0.2618 0.2487 0.2341 0.2181 0.2007 0.2121 0.2323 Columns 78 through 84 0.2512 0.2687 0.2850 0.3001 0.3139 0.3265 0.3380 Columns 85 through 91 0.3483 0.3576 0.3657 0.3727 0.3788 0.3837 0.3877 Columns 92 through 98 0.3908 0.3928 0.3940 0.3942 0.3935 0.3920 0.3896 Columns 99 through 100 0.3863 0.3823 max(abs(TempLinearPlot-TempExactPlot)) ans = 0.5255 max(abs(TempSplinePlot-TempExactPlot)) ans = 0.4445 save lecture4 clear