Cody

# Problem 150. chirp again

Solution 561850

Submitted on 21 Jan 2015 by Pritesh Shah
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
%% accu=10^6; f = 10000; fs=48000; your_chirp=round(chirping(f,fs)*accu)/accu; y_correct = round(chirp(0:1/fs:1-1/fs, 0,1,f,'linear',-90)*accu)/accu; assert(isequal(your_chirp,y_correct))

ans = Columns 1 through 9 0.0000 0.0000 0.0001 0.0001 0.0002 0.0003 0.0005 0.0007 0.0009 Columns 10 through 18 0.0011 0.0014 0.0016 0.0020 0.0023 0.0027 0.0031 0.0035 0.0039 Columns 19 through 27 0.0044 0.0049 0.0055 0.0060 0.0066 0.0072 0.0079 0.0085 0.0092 Columns 28 through 36 0.0099 0.0107 0.0115 0.0123 0.0131 0.0140 0.0148 0.0158 0.0167 Columns 37 through 45 0.0177 0.0187 0.0197 0.0207 0.0218 0.0229 0.0241 0.0252 0.0264 Columns 46 through 54 0.0276 0.0288 0.0301 0.0314 0.0327 0.0341 0.0355 0.0369 0.0383 Columns 55 through 63 0.0398 0.0412 0.0427 0.0443 0.0459 0.0474 0.0491 0.0507 0.0524 Columns 64 through 72 0.0541 0.0558 0.0576 0.0594 0.0612 0.0630 0.0649 0.0668 0.0687 Columns 73 through 81 0.0706 0.0726 0.0746 0.0766 0.0787 0.0808 0.0829 0.0850 0.0872 Columns 82 through 90 0.0893 0.0916 0.0938 0.0961 0.0984 0.1007 0.1030 0.1054 0.1078 Columns 91 through 99 0.1102 0.1127 0.1152 0.1177 0.1202 0.1227 0.1253 0.1279 0.1306 Columns 100 through 108 0.1332 0.1359 0.1386 0.1414 0.1442 0.1469 0.1498 0.1526 0.1555 Columns 109 through 117 0.1584 0.1613 0.1642 0.1672 0.1702 0.1732 0.1763 0.1794 0.1825 Columns 118 through 126 0.1856 0.1887 0.1919 0.1951 0.1983 0.2016 0.2048 0.2081 0.2114 Columns 127 through 135 0.2148 0.2182 0.2215 0.2250 0.2284 0.2319 0.2354 0.2389 0.2424 Columns 136 through 144 0.2460 0.2495 0.2531 0.2568 0.2604 0.2641 0.2678 0.2715 0.2752 Columns 145 through 153 0.2790 0.2828 0.2866 0.2904 0.2942 0.2981 0.3020 0.3059 0.3098 Columns 154 through 162 0.3138 0.3178 0.3218 0.3258 0.3298 0.3339 0.3379 0.3420 0.3461 Columns 163 through 171 0.3503 0.3544 0.3586 0.3628 0.3670 0.3712 0.3754 0.3797 0.3839 Columns 172 through 180 0.3882 0.3925 0.3969 0.4012 0.4056 0.4099 0.4143 0.4187 0.4231 Columns 181 through 189 0.4276 0.4320 0.4365 0.4409 0.4454 0.4499 0.4544 0.4590 0.4635 Columns 190 through 198 0.4680 0.4726 0.4772 0.4818 0.4863 0.4910 0.4956 0.5002 0.5048 Columns 199 through 207 0.5095 0.5141 0.5188 0.5234 0.5281 0.5328 0.5375 0.5422 0.5469 Columns 208 through 216 0.5516 0.5563 0.5610 0.5657 0.5705 0.5752 0.5799 0.5846 0.5894 Columns 217 through 225 0.5941 0.5989 0.6036 0.6083 0.6131 0.6178 0.6226 0.6273 0.6320 Columns 226 through 234 0.6368 0.6415 0.6462 0.6509 0.6557 0.6604 0.6651 0.6698 0.6745 Columns 235 through 243 0.6792 0.6838 0.6885 0.6932 0.6978 0.7025 0.7071 0.7117 0.7163 Columns 244 through 252 0.7209 0.7255 0.7301 0.7347 0.7392 0.7437 0.7482 0.7527 0.7572 Columns 253 through 261 0.7617 0.7661 0.7705 0.7750 0.7793 0.7837 0.7880 0.7924 0.7967 Columns 262 through 270 0.8009 0.8052 0.8094 0.8136 0.8178 0.8219 0.8260 0.8301 0.8342 Columns 271 through 279 0.8382 0.8422 0.8462 0.8501 0.8540 0.8579 0.8617 0.8655 0.8693 Columns 280 through 288 0.8730 0.8767 0.8804 0.8840 0.8876 0.8911 0.8946 0.8981 0.9015 Columns 289 through 297 0.9048 0.9081 0.9114 0.9147 0.9178 0.9210 0.9241 0.9271 0.9301 Columns 298 through 306 0.9330 0.9359 0.9388 0.9415 0.9443 0.9469 0.9496 0.9521 0.9546 Columns 307 through 315 0.9571 0.9595 0.9618 0.9641 0.9663 0.9684 0.9705 0.9725 0.9745 Columns 316 through 324 0.9764 0.9782 0.9799 0.9816 0.9833 0.9848 0.9863 0.9877 0.9890 Columns 325 through 333 0.9903 0.9915 0.9926 0.9936 0.9946 0.9955 0.9963 0.9970 0.9977 Columns 334 through 342 0.9983 0.9988 0.9992 0.9995 0.9998 0.9999 1.0000 1.0000 0.9999 Columns 343 through 351 0.9997 0.9994 0.9991 0.9986 0.9981 0.9975 0.9968 0.9960 0.9951 Columns 352 through 360 0.9941 0.9930 0.9918 0.9905 0.9891 0.9877 0.9861 0.9844 0.9827 Columns 361 through 369 0.9808 0.9788 0.9768 0.9746 0.9723 0.9699 0.9675 0.9649 0.9622 Columns 370 through 378 0.9594 0.9565 0.9535 0.9504 0.9472 0.9439 0.9405 0.9370 0.9333 Columns 379 through 387 0.9296 0.9257 0.9218 0.9177 0.9135 0.9092 0.9048 0.9003 0.8957 Columns 388 through 396 0.8910 0.8861 0.8811 0.8761 0.8709 0.8656 0.8602 0.8547 0.8490 Columns 397 through 405 0.8433 0.8374 0.8314 0.8254 0.8192 0.8128 0.8064 0.7999 0.7932 Columns 406 through 414 0.7865 0.7796 0.7726 0.7655 0.7583 0.7509 0.7435 0.7359 0.7283 Columns 415 through 423 0.7205 0.7126 0.7046 0.6965 0.6883 0.6800 0.6716 0.6630 0.6544 Columns 424 through 432 0.6456 0.6368 0.6278 0.6187 0.6095 0.6002 0.5909 0.5814 0.5718 Columns 433 through 441 0.5621 0.5523 0.5424 0.5324 0.5223 0.5121 0.5018 0.4915 0.4810 Columns 442 through 450 0.4704 0.4598 0.4490 0.4382 0.4272 0.4162 0.4051 0.3939 0.3827 Columns 451 through 459 0.3713 0.3599 0.3484 0.3368 0.3251 0.3134 0.3015 0.2896 0.2777 Columns 460 through 468 0.2656 0.2535 0.2414 0.2291 0.2169 0.2045 0.1921 0.1796 0.1671 Columns 469 through 477 0.1545 0.1419 0.1292 0.1164 0.1037 0.0908 0.0780 0.0651 0.0521 Columns 478 through 486 0.0391 0.0261 0.0131 0.0000 -0.0131 -0.0262 -0.0394 -0.0526 -0.0657 Columns 487 through 495 -0.0789 -0.0922 -0.1054 -0.1186 -0.1319 -0.1451 -0.1584 -0.1716 -0.1849 Columns 496 through 504 -0.1981 -0.2113 -0.2245 -0.2377 -0.2509 -0.2641 -0.2772 -0.2903 -0.3034 Columns 505 through 513 -0.3165 -0.3295 -0.3425 -0.3554 -0.3683 -0.3812 -0.3940 -0.4067 -0.4195 Columns 514 through 522 -0.4321 -0.4447 -0.4572 -0.4697 -0.4821 -0.4944 -0.5066 -0.5188 -0.5309 Columns 523 through 531 -0.5429 -0.5548 -0.5666 -0.5783 -0.5899 -0.6015 -0.6129 -0.6242 -0.6354 Columns 532 through 540 -0.6466 -0.6575 -0.6684 -0.6792 -0.6898 -0.7003 -0.7107 -0.7209 -0.7310 Columns 541 through 549 -0.7410 -0.7508 -0.7604 -0.7700 -0.7793 -0.7886 -0.7976 -0.8065 -0.8153 Columns 550 through 558 -0.8238 -0.8322 -0.8405 -0.8485 -0.8564 -0.8641 -0.8716 -0.8789 -0.8861 Columns 559 through 567 -0.8930 -0.8998 -0.9063 -0.9127 -0.9188 -0.9248 -0.9305 -0.9360 -0.9413 Columns 568 through 576 -0.9464 -0.9513 -0.9560 -0.9604 -0.9646 -0.9686 -0.9724 -0.9759 -0.9792 Columns 577 through 585 -0.9823 -0.9851 -0.9877 -0.9900 -0.9921 -0.9940 -0.9956 -0.9970 -0.9981 Columns 586 through 594 -0.9989 -0.9995 -0.9999 -1.0000 -0.9998 -0.9994 -0.9987 -0.9978 -0.9966 Columns 595 through 603 -0.9951 -0.9934 -0.9914 -0.9892 -0.9866 -0.9838 -0.9808 -0.9775 -0.9739 Columns 604 through 612 -0.9700 -0.9659 -0.9615 -0.9568 -0.9519 -0.9466 -0.9412 -0.9354 -0.9294 Columns 613 through 621 -0.9231 -0.9166 -0.9098 -0.9027 -0.8953 -0.8877 -0.8798 -0.8717 -0.8633 Columns 622 through 630 -0.8546 -0.8457 -0.8365 -0.8271 -0.8174 -0.8074 -0.7972 -0.7868 -0.7761 Columns 631 through 639 -0.7652 -0.7540 -0.7426 -0.7309 -0.7190 -0.7069 -0.6945 -0.6819 -0.6691 Columns 640 through 648 -0.6560 -0.6428 -0.6293 -0.6156 -0.6017 -0.5876 -0.5733 -0.5588 -0.5441 Columns 649 through 657 -0.5292 -0.5141 -0.4988 -0.4834 -0.4677 -0.4519 -0.4360 -0.4198 -0.4035 Columns 658 through 666 -0.3871 -0.3705 -0.3538 -0.3369 -0.3199 -0.3027 -0.2855 -0.2681 -0.2506 Columns 667 through 675 -0.2330 -0.2153 -0.1974 -0.1795 -0.1615 -0.1435 -0.1253 -0.1071 -0.0888 Columns 676 through 684 -0.0705 -0.0521 -0.0337 -0.0152 0.0033 0.0218 0.0404 0.0589 0.0775 Columns 685 through 693 0.0961 0.1146 0.1332 0.1517 0.1702 0.1887 0.2071 0.2255 0.2438 Columns 694 through 702 0.2621 0.2803 0.2984 0.3165 0.3344 0.3523 0.3701 0.3877 0.4053 Columns 703 through 711 0.4227 0.4400 0.4571 0.4741 0.4910 0.5076 0.5242 0.5405 0.5567 Columns 712 through 720 0.5727 0.5885 0.6041 0.6195 0.6347 0.6496 0.6643 0.6788 0.6931 Columns 721 through 729 0.7071 0.7209 0.7344 0.7476 0.7605 0.7732 0.7856 0.7977 0.8095 Columns 730 through 738 0.8210 0.8322 0.8431 0.8537 0.8639 0.8738 0.8834 0.8926 0.9015 Columns 739 through 747 0.9100 0.9181 0.9260 0.9334 0.9405 0.9471 0.9535 0.9594 0.9649 Columns 748 through 756 0.9701 0.9748 0.9792 0.9831 0.9866 0.9898 0.9925 0.9948 0.9967 Columns 757 through 765 0.9981 0.9992 0.9998 1.0000 0.9998 0.9991 0.9980 0.9965 0.9945 Columns 766 through 774 0.9921 0.9893 0.9860 0.9823 0....

2   Pass
%% accu=10^6; f = 3650; fs=44000; your_chirp=round(chirping(f,fs)*accu)/accu; y_correct = round(chirp(0:1/fs:1-1/fs, 0,1,f,'linear',-90)*accu)/accu; assert(isequal(your_chirp,y_correct))

ans = Columns 1 through 9 0.0000 0.0000 0.0000 0.0001 0.0001 0.0001 0.0002 0.0003 0.0004 Columns 10 through 18 0.0005 0.0006 0.0007 0.0009 0.0010 0.0012 0.0013 0.0015 0.0017 Columns 19 through 27 0.0019 0.0021 0.0024 0.0026 0.0029 0.0031 0.0034 0.0037 0.0040 Columns 28 through 36 0.0043 0.0046 0.0050 0.0053 0.0057 0.0061 0.0065 0.0068 0.0073 Columns 37 through 45 0.0077 0.0081 0.0086 0.0090 0.0095 0.0100 0.0104 0.0110 0.0115 Columns 46 through 54 0.0120 0.0125 0.0131 0.0136 0.0142 0.0148 0.0154 0.0160 0.0166 Columns 55 through 63 0.0173 0.0179 0.0186 0.0192 0.0199 0.0206 0.0213 0.0220 0.0228 Columns 64 through 72 0.0235 0.0243 0.0250 0.0258 0.0266 0.0274 0.0282 0.0290 0.0299 Columns 73 through 81 0.0307 0.0316 0.0324 0.0333 0.0342 0.0351 0.0360 0.0370 0.0379 Columns 82 through 90 0.0389 0.0398 0.0408 0.0418 0.0428 0.0438 0.0448 0.0459 0.0469 Columns 91 through 99 0.0480 0.0490 0.0501 0.0512 0.0523 0.0534 0.0546 0.0557 0.0569 Columns 100 through 108 0.0580 0.0592 0.0604 0.0616 0.0628 0.0640 0.0653 0.0665 0.0678 Columns 109 through 117 0.0690 0.0703 0.0716 0.0729 0.0742 0.0756 0.0769 0.0783 0.0796 Columns 118 through 126 0.0810 0.0824 0.0838 0.0852 0.0866 0.0880 0.0895 0.0909 0.0924 Columns 127 through 135 0.0939 0.0954 0.0969 0.0984 0.0999 0.1015 0.1030 0.1046 0.1062 Columns 136 through 144 0.1077 0.1093 0.1109 0.1126 0.1142 0.1158 0.1175 0.1191 0.1208 Columns 145 through 153 0.1225 0.1242 0.1259 0.1276 0.1294 0.1311 0.1329 0.1346 0.1364 Columns 154 through 162 0.1382 0.1400 0.1418 0.1436 0.1455 0.1473 0.1492 0.1510 0.1529 Columns 163 through 171 0.1548 0.1567 0.1586 0.1606 0.1625 0.1644 0.1664 0.1684 0.1703 Columns 172 through 180 0.1723 0.1743 0.1763 0.1784 0.1804 0.1824 0.1845 0.1866 0.1886 Columns 181 through 189 0.1907 0.1928 0.1949 0.1971 0.1992 0.2013 0.2035 0.2056 0.2078 Columns 190 through 198 0.2100 0.2122 0.2144 0.2166 0.2188 0.2211 0.2233 0.2256 0.2278 Columns 199 through 207 0.2301 0.2324 0.2347 0.2370 0.2393 0.2417 0.2440 0.2463 0.2487 Columns 208 through 216 0.2511 0.2535 0.2558 0.2582 0.2606 0.2631 0.2655 0.2679 0.2704 Columns 217 through 225 0.2728 0.2753 0.2778 0.2803 0.2828 0.2853 0.2878 0.2903 0.2928 Columns 226 through 234 0.2954 0.2979 0.3005 0.3031 0.3056 0.3082 0.3108 0.3134 0.3160 Columns 235 through 243 0.3187 0.3213 0.3239 0.3266 0.3292 0.3319 0.3346 0.3373 0.3400 Columns 244 through 252 0.3427 0.3454 0.3481 0.3508 0.3535 0.3563 0.3590 0.3618 0.3646 Columns 253 through 261 0.3673 0.3701 0.3729 0.3757 0.3785 0.3813 0.3841 0.3869 0.3898 Columns 262 through 270 0.3926 0.3955 0.3983 0.4012 0.4040 0.4069 0.4098 0.4127 0.4156 Columns 271 through 279 0.4185 0.4214 0.4243 0.4272 0.4302 0.4331 0.4360 0.4390 0.4419 Columns 280 through 288 0.4449 0.4478 0.4508 0.4538 0.4568 0.4598 0.4627 0.4657 0.4687 Columns 289 through 297 0.4717 0.4748 0.4778 0.4808 0.4838 0.4868 0.4899 0.4929 0.4960 Columns 298 through 306 0.4990 0.5021 0.5051 0.5082 0.5112 0.5143 0.5174 0.5204 0.5235 Columns 307 through 315 0.5266 0.5297 0.5328 0.5359 0.5390 0.5420 0.5451 0.5482 0.5513 Columns 316 through 324 0.5545 0.5576 0.5607 0.5638 0.5669 0.5700 0.5731 0.5762 0.5794 Columns 325 through 333 0.5825 0.5856 0.5887 0.5918 0.5950 0.5981 0.6012 0.6043 0.6075 Columns 334 through 342 0.6106 0.6137 0.6168 0.6199 0.6231 0.6262 0.6293 0.6324 0.6356 Columns 343 through 351 0.6387 0.6418 0.6449 0.6480 0.6511 0.6542 0.6573 0.6605 0.6636 Columns 352 through 360 0.6667 0.6698 0.6728 0.6759 0.6790 0.6821 0.6852 0.6883 0.6913 Columns 361 through 369 0.6944 0.6975 0.7005 0.7036 0.7067 0.7097 0.7128 0.7158 0.7188 Columns 370 through 378 0.7219 0.7249 0.7279 0.7309 0.7339 0.7369 0.7399 0.7429 0.7459 Columns 379 through 387 0.7488 0.7518 0.7547 0.7577 0.7606 0.7636 0.7665 0.7694 0.7723 Columns 388 through 396 0.7752 0.7781 0.7810 0.7839 0.7867 0.7896 0.7924 0.7953 0.7981 Columns 397 through 405 0.8009 0.8037 0.8065 0.8093 0.8121 0.8148 0.8176 0.8203 0.8230 Columns 406 through 414 0.8257 0.8284 0.8311 0.8338 0.8365 0.8391 0.8417 0.8444 0.8470 Columns 415 through 423 0.8496 0.8521 0.8547 0.8573 0.8598 0.8623 0.8648 0.8673 0.8698 Columns 424 through 432 0.8723 0.8747 0.8771 0.8795 0.8819 0.8843 0.8867 0.8890 0.8913 Columns 433 through 441 0.8936 0.8959 0.8982 0.9004 0.9027 0.9049 0.9071 0.9092 0.9114 Columns 442 through 450 0.9135 0.9157 0.9177 0.9198 0.9219 0.9239 0.9259 0.9279 0.9299 Columns 451 through 459 0.9318 0.9337 0.9356 0.9375 0.9394 0.9412 0.9430 0.9448 0.9466 Columns 460 through 468 0.9483 0.9500 0.9517 0.9534 0.9550 0.9566 0.9582 0.9598 0.9613 Columns 469 through 477 0.9628 0.9643 0.9658 0.9672 0.9686 0.9700 0.9713 0.9726 0.9739 Columns 478 through 486 0.9752 0.9764 0.9776 0.9788 0.9800 0.9811 0.9822 0.9832 0.9843 Columns 487 through 495 0.9853 0.9862 0.9872 0.9881 0.9890 0.9898 0.9906 0.9914 0.9921 Columns 496 through 504 0.9929 0.9935 0.9942 0.9948 0.9954 0.9959 0.9965 0.9969 0.9974 Columns 505 through 513 0.9978 0.9982 0.9985 0.9988 0.9991 0.9993 0.9995 0.9997 0.9998 Columns 514 through 522 0.9999 1.0000 1.0000 1.0000 0.9999 0.9998 0.9997 0.9995 0.9993 Columns 523 through 531 0.9991 0.9988 0.9985 0.9981 0.9977 0.9973 0.9968 0.9962 0.9957 Columns 532 through 540 0.9951 0.9944 0.9938 0.9930 0.9923 0.9915 0.9906 0.9897 0.9888 Columns 541 through 549 0.9878 0.9868 0.9857 0.9846 0.9835 0.9823 0.9811 0.9798 0.9785 Columns 550 through 558 0.9771 0.9757 0.9743 0.9728 0.9712 0.9696 0.9680 0.9663 0.9646 Columns 559 through 567 0.9629 0.9611 0.9592 0.9573 0.9554 0.9534 0.9513 0.9492 0.9471 Columns 568 through 576 0.9449 0.9427 0.9405 0.9381 0.9358 0.9334 0.9309 0.9284 0.9259 Columns 577 through 585 0.9233 0.9206 0.9179 0.9152 0.9124 0.9096 0.9067 0.9037 0.9008 Columns 586 through 594 0.8977 0.8947 0.8915 0.8884 0.8851 0.8819 0.8786 0.8752 0.8718 Columns 595 through 603 0.8683 0.8648 0.8612 0.8576 0.8539 0.8502 0.8465 0.8427 0.8388 Columns 604 through 612 0.8349 0.8309 0.8269 0.8229 0.8188 0.8146 0.8104 0.8062 0.8019 Columns 613 through 621 0.7975 0.7931 0.7887 0.7842 0.7796 0.7751 0.7704 0.7657 0.7610 Columns 622 through 630 0.7562 0.7513 0.7465 0.7415 0.7365 0.7315 0.7264 0.7213 0.7161 Columns 631 through 639 0.7109 0.7056 0.7003 0.6949 0.6895 0.6841 0.6785 0.6730 0.6674 Columns 640 through 648 0.6617 0.6560 0.6503 0.6445 0.6387 0.6328 0.6268 0.6209 0.6149 Columns 649 through 657 0.6088 0.6027 0.5965 0.5903 0.5841 0.5778 0.5714 0.5651 0.5586 Columns 658 through 666 0.5522 0.5457 0.5391 0.5325 0.5259 0.5192 0.5125 0.5057 0.4989 Columns 667 through 675 0.4920 0.4852 0.4782 0.4713 0.4642 0.4572 0.4501 0.4430 0.4358 Columns 676 through 684 0.4286 0.4214 0.4141 0.4068 0.3994 0.3920 0.3846 0.3771 0.3696 Columns 685 through 693 0.3621 0.3545 0.3469 0.3393 0.3316 0.3239 0.3162 0.3084 0.3006 Columns 694 through 702 0.2928 0.2849 0.2770 0.2691 0.2611 0.2531 0.2451 0.2371 0.2290 Columns 703 through 711 0.2209 0.2128 0.2046 0.1965 0.1883 0.1800 0.1718 0.1635 0.1552 Columns 712 through 720 0.1469 0.1385 0.1302 0.1218 0.1134 0.1050 0.0965 0.0881 0.0796 Columns 721 through 729 0.0711 0.0626 0.0540 0.0455 0.0369 0.0283 0.0198 0.0111 0.0025 Columns 730 through 738 -0.0061 -0.0147 -0.0234 -0.0321 -0.0407 -0.0494 -0.0581 -0.0668 -0.0755 Columns 739 through 747 -0.0842 -0.0929 -0.1016 -0.1104 -0.1191 -0.1278 -0.1365 -0.1453 -0.1540 Columns 748 through 756 -0.1627 -0.1715 -0.1802 -0.1889 -0.1976 -0.2064 -0.2151 -0.2238 -0.2325 Columns 757 through 765 -0.2412 -0.2499 -0.2585 -0.2672 -0.2759 -0.2845 -0.2932 -0.3018 -0.3104 Columns 766 through 774 -0.3190 -0.3276 -0.3361 -0.3447 -0....