Cody

# Problem 44934. Plot Damped Sinusoid

Solution 1992090

Submitted on 26 Oct 2019 by Romain Demory
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   Pass
t = linspace(0,15,400); y = exp(-0.5*t).*cos(2*pi.*t); m = plot_cos(y, t); f = gcf; assert(isequal([f.Children.Children.Color], [1 0 0 0 0 1])) assert(strcmp([f.Children.Children.LineStyle], 'none--')) assert(strcmp([f.Children.Children.Marker],'*none')) assert(isequal([f.Children.Children.YData],[m, y]))

f = Figure (1) with properties: Number: 1 Name: '' Color: [1 1 1] Position: [508 656 583 437] Units: 'pixels' Show all properties ans = 1 0 0 ans = 0 0 1 ans = 'none' ans = '--' ans = '*' ans = 'none' ans = -0.7812 ans = Columns 1 through 18 1.0000 0.9541 0.8576 0.7176 0.5434 0.3459 0.1366 -0.0724 -0.2697 -0.4450 -0.5894 -0.6961 -0.7607 -0.7812 -0.7581 -0.6943 -0.5947 -0.4662 Columns 19 through 36 -0.3169 -0.1557 0.0081 0.1654 0.3079 0.4282 0.5205 0.5809 0.6073 0.5993 0.5588 0.4891 0.3951 0.2830 0.1595 0.0317 -0.0930 -0.2081 Columns 37 through 54 -0.3074 -0.3863 -0.4411 -0.4696 -0.4713 -0.4472 -0.3994 -0.3314 -0.2478 -0.1536 -0.0546 0.0439 0.1362 0.2177 0.2843 0.3328 0.3613 0.3689 Columns 55 through 72 0.3559 0.3240 0.2754 0.2136 0.1423 0.0658 -0.0115 -0.0852 -0.1516 -0.2072 -0.2494 -0.2764 -0.2872 -0.2818 -0.2612 -0.2271 -0.1817 -0.1280 Columns 73 through 90 -0.0693 -0.0090 0.0496 0.1033 0.1494 0.1856 0.2103 0.2225 0.2220 0.2094 0.1858 0.1529 0.1128 0.0680 0.0211 -0.0252 -0.0685 -0.1063 Columns 91 through 108 -0.1370 -0.1590 -0.1714 -0.1741 -0.1670 -0.1511 -0.1274 -0.0977 -0.0637 -0.0274 0.0090 0.0436 0.0745 0.1002 0.1194 0.1314 0.1357 0.1325 Columns 109 through 126 0.1221 0.1053 0.0834 0.0578 0.0299 0.0014 -0.0261 -0.0512 -0.0725 -0.0891 -0.1002 -0.1053 -0.1045 -0.0980 -0.0864 -0.0705 -0.0512 -0.0299 Columns 127 through 144 -0.0077 0.0141 0.0343 0.0518 0.0659 0.0759 0.0813 0.0821 0.0783 0.0704 0.0589 0.0446 0.0284 0.0112 -0.0059 -0.0221 -0.0365 -0.0484 Columns 145 through 162 -0.0571 -0.0624 -0.0641 -0.0622 -0.0570 -0.0488 -0.0383 -0.0260 -0.0128 0.0007 0.0136 0.0253 0.0351 0.0427 0.0477 0.0498 0.0492 0.0459 Columns 163 through 180 0.0401 0.0324 0.0232 0.0131 0.0026 -0.0076 -0.0171 -0.0252 -0.0317 -0.0362 -0.0385 -0.0387 -0.0367 -0.0328 -0.0272 -0.0203 -0.0126 -0.0045 Columns 181 through 198 0.0036 0.0112 0.0179 0.0233 0.0273 0.0297 0.0303 0.0292 0.0266 0.0226 0.0175 0.0117 0.0054 -0.0009 -0.0070 -0.0124 -0.0170 -0.0205 Columns 199 through 216 -0.0227 -0.0236 -0.0231 -0.0214 -0.0186 -0.0149 -0.0105 -0.0057 -0.0007 0.0041 0.0085 0.0123 0.0152 0.0173 0.0183 0.0182 0.0172 0.0153 Columns 217 through 234 0.0125 0.0093 0.0056 0.0017 -0.0021 -0.0056 -0.0087 -0.0112 -0.0131 -0.0141 -0.0143 -0.0137 -0.0124 -0.0105 -0.0080 -0.0052 -0.0022 0.0007 Columns 235 through 252 0.0036 0.0061 0.0082 0.0098 0.0108 0.0111 0.0109 0.0100 0.0086 0.0068 0.0047 0.0025 0.0001 -0.0021 -0.0042 -0.0060 -0.0073 -0.0082 Columns 253 through 270 -0.0086 -0.0086 -0.0080 -0.0071 -0.0058 -0.0042 -0.0025 -0.0006 0.0012 0.0028 0.0043 0.0054 0.0062 0.0067 0.0067 0.0064 0.0058 0.0048 Columns 271 through 288 0.0037 0.0023 0.0009 -0.0005 -0.0018 -0.0030 -0.0040 -0.0047 -0.0051 -0.0053 -0.0051 -0.0047 -0.0040 -0.0031 -0.0021 -0.0010 0.0001 0.0011 Columns 289 through 306 0.0021 0.0029 0.0035 0.0039 0.0041 0.0040 0.0038 0.0033 0.0027 0.0019 0.0011 0.0002 -0.0006 -0.0014 -0.0021 -0.0026 -0.0030 -0.0032 Columns 307 through 324 -0.0032 -0.0030 -0.0027 -0.0022 -0.0017 -0.0010 -0.0004 0.0003 0.0009 0.0015 0.0019 0.0022 0.0024 0.0025 0.0024 0.0022 0.0019 0.0014 Columns 325 through 342 0.0010 0.0004 -0.0001 -0.0006 -0.0010 -0.0014 -0.0017 -0.0019 -0.0019 -0.0019 -0.0018 -0.0015 -0.0012 -0.0009 -0.0005 -0.0001 0.0003 0.0007 Columns 343 through 360 0.0010 0.0013 0.0014 0.0015 0.0015 0.0014 0.0013 0.0010 0.0008 0.0005 0.0001 -0.0002 -0.0005 -0.0007 -0.0009 -0.0011 -0.0012 -0.0012 Columns 361 through 378 -0.0011 -0.0010 -0.0009 -0.0007 -0.0004 -0.0002 0.0001 0.0003 0.0005 0.0007 0.0008 0.0009 0.0009 0.0009 0.0008 0.0007 0.0006 0.0004 Columns 379 through 396 0.0002 0.0000 -0.0002 -0.0003 -0.0005 -0.0006 -0.0007 -0.0007 -0.0007 -0.0007 -0.0006 -0.0005 -0.0003 -0.0002 -0.0001 0.0001 0.0002 0.0003 Columns 397 through 400 0.0004 0.0005 0.0005 0.0006

2   Pass
t = linspace(2,5,100); y = exp(-0.5*t).*cos(2*pi.*t); m = plot_cos(y, t); f = gcf; assert(isequal([f.Children.Children.Color], [1 0 0 0 0 1])) assert(strcmp([f.Children.Children.LineStyle], 'none--')) assert(strcmp([f.Children.Children.Marker],'*none')) assert(isequal([f.Children.Children.YData],[m, y]))

f = Figure (2) with properties: Number: 2 Name: '' Color: [1 1 1] Position: [508 656 583 437] Units: 'pixels' Show all properties ans = 1 0 0 ans = 0 0 1 ans = 'none' ans = '--' ans = '*' ans = 'none' ans = -0.2874 ans = Columns 1 through 18 0.3679 0.3558 0.3313 0.2957 0.2506 0.1978 0.1395 0.0780 0.0155 -0.0457 -0.1034 -0.1557 -0.2009 -0.2375 -0.2645 -0.2812 -0.2874 -0.2831 Columns 19 through 36 -0.2687 -0.2452 -0.2136 -0.1753 -0.1318 -0.0849 -0.0364 0.0120 0.0585 0.1015 0.1396 0.1716 0.1964 0.2135 0.2224 0.2231 0.2158 0.2010 Columns 37 through 54 0.1794 0.1520 0.1200 0.0846 0.0473 0.0094 -0.0277 -0.0627 -0.0944 -0.1218 -0.1440 -0.1604 -0.1706 -0.1743 -0.1717 -0.1630 -0.1487 -0.1295 Columns 55 through 72 -0.1063 -0.0799 -0.0515 -0.0221 0.0073 0.0355 0.0616 0.0847 0.1041 0.1191 0.1295 0.1349 0.1353 0.1309 0.1219 0.1088 0.0922 0.0728 Columns 73 through 90 0.0513 0.0287 0.0057 -0.0168 -0.0380 -0.0573 -0.0739 -0.0874 -0.0973 -0.1035 -0.1057 -0.1041 -0.0989 -0.0902 -0.0786 -0.0645 -0.0485 -0.0312 Columns 91 through 100 -0.0134 0.0044 0.0215 0.0373 0.0514 0.0631 0.0723 0.0785 0.0818 0.0821