Cody

Problem 44934. Plot Damped Sinusoid

Solution 2489402

Submitted on 7 Jun 2020 by Tobias Müller
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
clf; t = linspace(0,15,400); y = exp(-0.5*t).*cos(2*pi.*t); m = plot_cos(y, t); assert(abs(m - (-0.781239288889930)) <= 1e-4) h = findobj(gcf, 'Type', 'Line'); if length(h) == 2 assert(isequal([h.Color], [1 0 0 0 0 1]), 'Check plot colors') assert(strcmp([h.LineStyle], 'none--'), 'Check the line style') assert(strcmp([h.Marker],'*none'), 'Check marker type') assert(isequal([h.YData],[m, y]), 'Check plotted data') elseif length(h) == 1 assert(isequal([h.Color], [0 0 1]),'Check plot colors') assert(strcmp([h.LineStyle], '--'), 'Check the line style') assert(strcmp([h.Marker],'*'),'Check marker type') assert(isequal([h.YData],y),'Check plotted data' ) assert(isequal([h.MarkerEdgeColor], [1 0 0]),'Check plot colors') assert(isequal([h.MarkerIndices], 14),'Check marker location') elseif length(h)>2 error('There may be too many plots on the figure.') else error('No plot found.') end

y_new = Columns 1 through 18 -0.7812 -0.7607 -0.7581 -0.6961 -0.6943 -0.5947 -0.5894 -0.4713 -0.4696 -0.4662 -0.4472 -0.4450 -0.4411 -0.3994 -0.3863 -0.3314 -0.3169 -0.3074 Columns 19 through 36 -0.2872 -0.2818 -0.2764 -0.2697 -0.2612 -0.2494 -0.2478 -0.2271 -0.2081 -0.2072 -0.1817 -0.1741 -0.1714 -0.1670 -0.1590 -0.1557 -0.1536 -0.1516 Columns 37 through 54 -0.1511 -0.1370 -0.1280 -0.1274 -0.1063 -0.1053 -0.1045 -0.1002 -0.0980 -0.0977 -0.0930 -0.0891 -0.0864 -0.0852 -0.0725 -0.0724 -0.0705 -0.0693 Columns 55 through 72 -0.0685 -0.0641 -0.0637 -0.0624 -0.0622 -0.0571 -0.0570 -0.0546 -0.0512 -0.0512 -0.0488 -0.0484 -0.0387 -0.0385 -0.0383 -0.0367 -0.0365 -0.0362 Columns 73 through 90 -0.0328 -0.0317 -0.0299 -0.0274 -0.0272 -0.0261 -0.0260 -0.0252 -0.0252 -0.0236 -0.0231 -0.0227 -0.0221 -0.0214 -0.0205 -0.0203 -0.0186 -0.0171 Columns 91 through 108 -0.0170 -0.0149 -0.0143 -0.0141 -0.0137 -0.0131 -0.0128 -0.0126 -0.0124 -0.0124 -0.0115 -0.0112 -0.0105 -0.0105 -0.0090 -0.0087 -0.0086 -0.0086 Columns 109 through 126 -0.0082 -0.0080 -0.0080 -0.0077 -0.0076 -0.0073 -0.0071 -0.0070 -0.0060 -0.0059 -0.0058 -0.0057 -0.0056 -0.0053 -0.0052 -0.0051 -0.0051 -0.0047 Columns 127 through 144 -0.0047 -0.0045 -0.0042 -0.0042 -0.0040 -0.0040 -0.0032 -0.0032 -0.0031 -0.0030 -0.0030 -0.0030 -0.0027 -0.0026 -0.0025 -0.0022 -0.0022 -0.0021 Columns 145 through 162 -0.0021 -0.0021 -0.0021 -0.0019 -0.0019 -0.0019 -0.0018 -0.0018 -0.0017 -0.0017 -0.0015 -0.0014 -0.0014 -0.0012 -0.0012 -0.0012 -0.0011 -0.0011 Columns 163 through 180 -0.0010 -0.0010 -0.0010 -0.0010 -0.0009 -0.0009 -0.0009 -0.0009 -0.0007 -0.0007 -0.0007 -0.0007 -0.0007 -0.0007 -0.0007 -0.0006 -0.0006 -0.0006 Columns 181 through 198 -0.0006 -0.0006 -0.0005 -0.0005 -0.0005 -0.0005 -0.0005 -0.0004 -0.0004 -0.0003 -0.0003 -0.0002 -0.0002 -0.0002 -0.0002 -0.0001 -0.0001 -0.0001 Columns 199 through 216 0.0000 0.0001 0.0001 0.0001 0.0001 0.0001 0.0002 0.0002 0.0002 0.0003 0.0003 0.0003 0.0003 0.0004 0.0004 0.0004 0.0005 0.0005 Columns 217 through 234 0.0005 0.0005 0.0006 0.0006 0.0007 0.0007 0.0007 0.0007 0.0007 0.0008 0.0008 0.0008 0.0009 0.0009 0.0009 0.0009 0.0009 0.0010 Columns 235 through 252 0.0010 0.0010 0.0011 0.0011 0.0012 0.0013 0.0013 0.0014 0.0014 0.0014 0.0014 0.0015 0.0015 0.0015 0.0017 0.0019 0.0019 0.0019 Columns 253 through 270 0.0021 0.0022 0.0022 0.0023 0.0024 0.0024 0.0025 0.0025 0.0026 0.0027 0.0028 0.0029 0.0033 0.0035 0.0036 0.0036 0.0037 0.0038 Columns 271 through 288 0.0039 0.0040 0.0041 0.0041 0.0043 0.0047 0.0048 0.0054 0.0054 0.0056 0.0058 0.0061 0.0062 0.0064 0.0067 0.0067 0.0068 0.0081 Columns 289 through 306 0.0082 0.0085 0.0086 0.0090 0.0093 0.0098 0.0100 0.0108 0.0109 0.0111 0.0112 0.0112 0.0117 0.0123 0.0125 0.0131 0.0136 0.0141 Columns 307 through 324 0.0152 0.0153 0.0172 0.0173 0.0175 0.0179 0.0182 0.0183 0.0211 0.0226 0.0232 0.0233 0.0253 0.0266 0.0273 0.0284 0.0292 0.0297 Columns 325 through 342 0.0299 0.0303 0.0317 0.0324 0.0343 0.0351 0.0401 0.0427 0.0436 0.0439 0.0446 0.0459 0.0477 0.0492 0.0496 0.0498 0.0518 0.0578 Columns 343 through 360 0.0589 0.0658 0.0659 0.0680 0.0704 0.0745 0.0759 0.0783 0.0813 0.0821 0.0834 0.1002 0.1033 0.1053 0.1128 0.1194 0.1221 0.1314 Columns 361 through 378 0.1325 0.1357 0.1362 0.1366 0.1423 0.1494 0.1529 0.1595 0.1654 0.1856 0.1858 0.2094 0.2103 0.2136 0.2177 0.2220 0.2225 0.2754 Columns 379 through 396 0.2830 0.2843 0.3079 0.3240 0.3328 0.3459 0.3559 0.3613 0.3689 0.3951 0.4282 0.4891 0.5205 0.5434 0.5588 0.5809 0.5993 0.6073 Columns 397 through 400 0.7176 0.8576 0.9541 1.0000 IDs = Columns 1 through 30 14 13 15 12 16 17 11 41 40 18 42 10 39 43 38 44 19 37 67 68 66 9 69 65 45 70 36 64 71 94 Columns 31 through 60 93 95 92 20 46 63 96 91 72 97 90 120 121 119 122 98 35 118 123 62 117 8 124 73 89 147 99 146 148 145 Columns 61 through 90 149 47 125 116 150 144 174 173 151 175 143 172 176 171 126 100 177 115 152 88 170 200 201 199 142 202 198 178 203 169 Columns 91 through 120 197 204 227 226 228 225 153 179 196 229 61 224 205 230 74 223 253 254 252 255 231 127 168 251 256 195 250 141 257 206 Columns 121 through 150 222 280 232 279 281 278 282 180 258 249 283 277 307 306 284 308 276 305 309 304 259 233 310 248 285 221 303 333 334 332 Columns 151 through 180 275 335 331 311 336 302 330 337 360 359 361 358 286 312 329 362 194 357 338 363 207 356 386 387 385 388 364 260 301 384 Columns 181 through 210 389 328 383 274 390 339 355 365 313 391 382 392 366 381 354 327 340 393 380 287 367 394 247 353 379 300 395 368 314 341 Columns 211 through 240 396 378 326 397 352 369 398 399 400 377 154 370 342 376 234 351 371 375 372 374 373 315 273 325 343 350 299 288 261 344 Columns 241 through 270 349 348 114 345 324 316 347 346 220 323 298 317 289 322 318 272 321 319 246 320 167 297 262 290 296 291 235 181 271 295 Columns 271 through 300 292 294 208 293 263 245 270 193 264 219 269 236 265 268 266 267 244 21 237 209 243 101 218 238 242 239 241 240 182 140 Columns 301 through 330 192 210 217 166 155 128 211 216 215 212 191 183 214 213 87 190 165 184 156 189 185 139 188 186 113 187 34 164 129 157 Columns 331 through 360 163 158 102 48 138 162 159 161 75 160 130 112 137 60 131 86 136 103 132 135 133 134 111 104 76 110 85 105 109 106 Columns 361 through 390 108 107 49 7 59 77 84 33 22 78 83 82 79 58 50 81 80 57 32 51 23 56 52 6 55 53 54 31 24 30 Columns 391 through 400 25 5 29 26 28 27 4 3 2 1 t_new = Columns 1 through 18 0.4887 0.4511 0.5263 0.4135 0.5639 0.6015 0.3759 1.5038 1.4662 0.6391 1.5414 0.3383 1.4286 1.5789 1.3910 1.6165 0.6767 1.3534 Columns 19 through 36 2.4812 2.5188 2.4436 0.3008 2.5564 2.4060 1.6541 2.5940 1.3158 2.3684 2.6316 3.4962 3.4586 3.5338 3.4211 0.7143 1.6917 2.3308 Columns 37 through 54 3.5714 3.3835 2.6692 3.6090 3.3459 4.4737 4.5113 4.4361 4.5489 3.6466 1.2782 4.3985 4.5865 2.2932 4.3609 0.2632 4.6241 2.7068 Columns 55 through 72 3.3083 5.4887 3.6842 5.4511 5.5263 5.4135 5.5639 1.7293 4.6617 4.3233 5.6015 5.3759 6.5038 6.4662 5.6391 6.5414 5.3383 6.4286 Columns 73 through 90 6.5789 6.3910 4.6992 3.7218 6.6165 4.2857 5.6767 3.2707 6.3534 7.4812 7.5188 7.4436 5.3008 7.5564 7.4060 6.6541 7.5940 6.3158 Columns 91 through 108 7.3684 7.6316 8.4962 8.4586 8.5338 8.4211 5.7143 6.6917 7.3308 8.5714 2.2556 8.3835 7.6692 8.6090 2.7444 8.3459 9.4737 9.5113 Columns 109 through 126 9.4361 9.5489 8.6466 4.7368 6.2782 9.3985 9.5865 7.2932 9.3609 5.2632 9.6241 7.7068 8.3083 10.4887 8.6842 10.4511 10.5263 10.4135 Columns 127 through 144 10.5639 6.7293 9.6617 9.3233 10.6015 10.3759 11.5038 11.4662 10.6391 11.5414 10.3383 11.4286 11.5789 11.3910 9.6992 8.7218 11.6165 9.2857 Columns 145 through 162 10.6767 8.2707 11.3534 12.4812 12.5188 12.4436 10.3008 12.5564 12.4060 11.6541 12.5940 11.3158 12.3684 12.6316 13.4962 13.4586 13.5338 13.4211 Columns 163 through 180 10.7143 11.6917 12.3308 13.5714 7.2556 13.3835 12.6692 13.6090 7.7444 13.3459 14.4737 14.5113 14.4361 14.5489 13.6466 9.7368 11.2782 14.3985 Columns 181 through 198 14.5865 12.2932 14.3609 10.2632 14.6241 12.7068 13.3083 13.6842 11.7293 14.6617 14.3233 14.6992 13.7218 14.2857 13.2707 12.2556 12.7444 14.7368 Columns 199 through 216 14.2481 10.7519 13.7594 14.7744 9.2481 13.2331 14.2105 11.2406 14.8120 13.7970 11.7669 12.7820 14.8496 14.1729 12.2180 14.8872 13.1955 13.8346 Columns 217 through 23...

  
2   Pass
clf; t = linspace(2,5,100); y = exp(-0.5*t).*cos(2*pi.*t); m = plot_cos(y, t); assert(abs(m - (-0.287376348726584)) <= 1e-4) h = findobj(gcf, 'Type', 'Line'); if length(h) == 2 assert(isequal([h.Color], [1 0 0 0 0 1]), 'Check plot colors') assert(strcmp([h.LineStyle], 'none--'), 'Check the line style') assert(strcmp([h.Marker],'*none'), 'Check marker type') assert(isequal([h.YData],[m, y]), 'Check plotted data') elseif length(h) == 1 assert(isequal([h.Color], [0 0 1]),'Check plot colors') assert(strcmp([h.LineStyle], '--'), 'Check the line style') assert(strcmp([h.Marker],'*'),'Check marker type') assert(isequal([h.YData],y),'Check plotted data' ) assert(isequal([h.MarkerEdgeColor], [1 0 0]),'Check plot colors') assert(isequal([h.MarkerIndices],17 ),'Check marker location') elseif length(h)>2 error('There may be too many plots on the figure.') else error('No plot found.') end

y_new = Columns 1 through 18 -0.2874 -0.2831 -0.2812 -0.2687 -0.2645 -0.2452 -0.2375 -0.2136 -0.2009 -0.1753 -0.1743 -0.1717 -0.1706 -0.1630 -0.1604 -0.1557 -0.1487 -0.1440 Columns 19 through 36 -0.1318 -0.1295 -0.1218 -0.1063 -0.1057 -0.1041 -0.1035 -0.1034 -0.0989 -0.0973 -0.0944 -0.0902 -0.0874 -0.0849 -0.0799 -0.0786 -0.0739 -0.0645 Columns 37 through 54 -0.0627 -0.0573 -0.0515 -0.0485 -0.0457 -0.0380 -0.0364 -0.0312 -0.0277 -0.0221 -0.0168 -0.0134 0.0044 0.0057 0.0073 0.0094 0.0120 0.0155 Columns 55 through 72 0.0215 0.0287 0.0355 0.0373 0.0473 0.0513 0.0514 0.0585 0.0616 0.0631 0.0723 0.0728 0.0780 0.0785 0.0818 0.0821 0.0846 0.0847 Columns 73 through 90 0.0922 0.1015 0.1041 0.1088 0.1191 0.1200 0.1219 0.1295 0.1309 0.1349 0.1353 0.1395 0.1396 0.1520 0.1716 0.1794 0.1964 0.1978 Columns 91 through 100 0.2010 0.2135 0.2158 0.2224 0.2231 0.2506 0.2957 0.3313 0.3558 0.3679 IDs = Columns 1 through 30 17 18 16 19 15 20 14 21 13 22 50 51 49 52 48 12 53 47 23 54 46 55 83 84 82 11 85 81 45 86 Columns 31 through 60 80 24 56 87 79 88 44 78 57 89 10 77 25 90 43 58 76 91 92 75 59 42 26 9 93 74 60 94 41 73 Columns 61 through 90 95 27 61 96 97 72 8 98 99 100 40 62 71 28 63 70 64 39 69 65 68 66 67 7 29 38 30 37 31 6 Columns 91 through 100 36 32 35 33 34 5 4 3 2 1 t_new = Columns 1 through 18 2.4848 2.5152 2.4545 2.5455 2.4242 2.5758 2.3939 2.6061 2.3636 2.6364 3.4848 3.5152 3.4545 3.5455 3.4242 2.3333 3.5758 3.3939 Columns 19 through 36 2.6667 3.6061 3.3636 3.6364 4.4848 4.5152 4.4545 2.3030 4.5455 4.4242 3.3333 4.5758 4.3939 2.6970 3.6667 4.6061 4.3636 4.6364 Columns 37 through 54 3.3030 4.3333 3.6970 4.6667 2.2727 4.3030 2.7273 4.6970 3.2727 3.7273 4.2727 4.7273 4.7576 4.2424 3.7576 3.2424 2.7576 2.2424 Columns 55 through 72 4.7879 4.2121 3.7879 4.8182 3.2121 4.1818 4.8485 2.7879 3.8182 4.8788 4.9091 4.1515 2.2121 4.9394 4.9697 5.0000 3.1818 3.8485 Columns 73 through 90 4.1212 2.8182 3.8788 4.0909 3.9091 3.1515 4.0606 3.9394 4.0303 3.9697 4.0000 2.1818 2.8485 3.1212 2.8788 3.0909 2.9091 2.1515 Columns 91 through 100 3.0606 2.9394 3.0303 2.9697 3.0000 2.1212 2.0909 2.0606 2.0303 2.0000

  

Suggested Problems

More from this Author13

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!