Why is my FFT diagram has a slope approaching to zero?

2 views (last 30 days)
Hello,
I don't know why am I not getting proper FFT diagram. I am getting a slope which goes to zero. Can someone help me?
Fs=1000;
T=1/Fs;
t1=readtable('t.xlsx')
t1 = 2×849 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10 Var11 Var12 Var13 Var14 Var15 Var16 Var17 Var18 Var19 Var20 Var21 Var22 Var23 Var24 Var25 Var26 Var27 Var28 Var29 Var30 Var31 Var32 Var33 Var34 Var35 Var36 Var37 Var38 Var39 Var40 Var41 Var42 Var43 Var44 Var45 Var46 Var47 Var48 Var49 Var50 Var51 Var52 Var53 Var54 Var55 Var56 Var57 Var58 Var59 Var60 Var61 Var62 Var63 Var64 Var65 Var66 Var67 Var68 Var69 Var70 Var71 Var72 Var73 Var74 Var75 Var76 Var77 Var78 Var79 Var80 Var81 Var82 Var83 Var84 Var85 Var86 Var87 Var88 Var89 Var90 Var91 Var92 Var93 Var94 Var95 Var96 Var97 Var98 Var99 Var100 Var101 Var102 Var103 Var104 Var105 Var106 Var107 Var108 Var109 Var110 Var111 Var112 Var113 Var114 Var115 Var116 Var117 Var118 Var119 Var120 Var121 Var122 Var123 Var124 Var125 Var126 Var127 Var128 Var129 Var130 Var131 Var132 Var133 Var134 Var135 Var136 Var137 Var138 Var139 Var140 Var141 Var142 Var143 Var144 Var145 Var146 Var147 Var148 Var149 Var150 Var151 Var152 Var153 Var154 Var155 Var156 Var157 Var158 Var159 Var160 Var161 Var162 Var163 Var164 Var165 Var166 Var167 Var168 Var169 Var170 Var171 Var172 Var173 Var174 Var175 Var176 Var177 Var178 Var179 Var180 Var181 Var182 Var183 Var184 Var185 Var186 Var187 Var188 Var189 Var190 Var191 Var192 Var193 Var194 Var195 Var196 Var197 Var198 Var199 Var200 Var201 Var202 Var203 Var204 Var205 Var206 Var207 Var208 Var209 Var210 Var211 Var212 Var213 Var214 Var215 Var216 Var217 Var218 Var219 Var220 Var221 Var222 Var223 Var224 Var225 Var226 Var227 Var228 Var229 Var230 Var231 Var232 Var233 Var234 Var235 Var236 Var237 Var238 Var239 Var240 Var241 Var242 Var243 Var244 Var245 Var246 Var247 Var248 Var249 Var250 Var251 Var252 Var253 Var254 Var255 Var256 Var257 Var258 Var259 Var260 Var261 Var262 Var263 Var264 Var265 Var266 Var267 Var268 Var269 Var270 Var271 Var272 Var273 Var274 Var275 Var276 Var277 Var278 Var279 Var280 Var281 Var282 Var283 Var284 Var285 Var286 Var287 Var288 Var289 Var290 Var291 Var292 Var293 Var294 Var295 Var296 Var297 Var298 Var299 Var300 Var301 Var302 Var303 Var304 Var305 Var306 Var307 Var308 Var309 Var310 Var311 Var312 Var313 Var314 Var315 Var316 Var317 Var318 Var319 Var320 Var321 Var322 Var323 Var324 Var325 Var326 Var327 Var328 Var329 Var330 Var331 Var332 Var333 Var334 Var335 Var336 Var337 Var338 Var339 Var340 Var341 Var342 Var343 Var344 Var345 Var346 Var347 Var348 Var349 Var350 Var351 Var352 Var353 Var354 Var355 Var356 Var357 Var358 Var359 Var360 Var361 Var362 Var363 Var364 Var365 Var366 Var367 Var368 Var369 Var370 Var371 Var372 Var373 Var374 Var375 Var376 Var377 Var378 Var379 Var380 Var381 Var382 Var383 Var384 Var385 Var386 Var387 Var388 Var389 Var390 Var391 Var392 Var393 Var394 Var395 Var396 Var397 Var398 Var399 Var400 Var401 Var402 Var403 Var404 Var405 Var406 Var407 Var408 Var409 Var410 Var411 Var412 Var413 Var414 Var415 Var416 Var417 Var418 Var419 Var420 Var421 Var422 Var423 Var424 Var425 Var426 Var427 Var428 Var429 Var430 Var431 Var432 Var433 Var434 Var435 Var436 Var437 Var438 Var439 Var440 Var441 Var442 Var443 Var444 Var445 Var446 Var447 Var448 Var449 Var450 Var451 Var452 Var453 Var454 Var455 Var456 Var457 Var458 Var459 Var460 Var461 Var462 Var463 Var464 Var465 Var466 Var467 Var468 Var469 Var470 Var471 Var472 Var473 Var474 Var475 Var476 Var477 Var478 Var479 Var480 Var481 Var482 Var483 Var484 Var485 Var486 Var487 Var488 Var489 Var490 Var491 Var492 Var493 Var494 Var495 Var496 Var497 Var498 Var499 Var500 Var501 Var502 Var503 Var504 Var505 Var506 Var507 Var508 Var509 Var510 Var511 Var512 Var513 Var514 Var515 Var516 Var517 Var518 Var519 Var520 Var521 Var522 Var523 Var524 Var525 Var526 Var527 Var528 Var529 Var530 Var531 Var532 Var533 Var534 Var535 Var536 Var537 Var538 Var539 Var540 Var541 Var542 Var543 Var544 Var545 Var546 Var547 Var548 Var549 Var550 Var551 Var552 Var553 Var554 Var555 Var556 Var557 Var558 Var559 Var560 Var561 Var562 Var563 Var564 Var565 Var566 Var567 Var568 Var569 Var570 Var571 Var572 Var573 Var574 Var575 Var576 Var577 Var578 Var579 Var580 Var581 Var582 Var583 Var584 Var585 Var586 Var587 Var588 Var589 Var590 Var591 Var592 Var593 Var594 Var595 Var596 Var597 Var598 Var599 Var600 Var601 Var602 Var603 Var604 Var605 Var606 Var607 Var608 Var609 Var610 Var611 Var612 Var613 Var614 Var615 Var616 Var617 Var618 Var619 Var620 Var621 Var622 Var623 Var624 Var625 Var626 Var627 Var628 Var629 Var630 Var631 Var632 Var633 Var634 Var635 Var636 Var637 Var638 Var639 Var640 Var641 Var642 Var643 Var644 Var645 Var646 Var647 Var648 Var649 Var650 Var651 Var652 Var653 Var654 Var655 Var656 Var657 Var658 Var659 Var660 Var661 Var662 Var663 Var664 Var665 Var666 Var667 Var668 Var669 Var670 Var671 Var672 Var673 Var674 Var675 Var676 Var677 Var678 Var679 Var680 Var681 Var682 Var683 Var684 Var685 Var686 Var687 Var688 Var689 Var690 Var691 Var692 Var693 Var694 Var695 Var696 Var697 Var698 Var699 Var700 Var701 Var702 Var703 Var704 Var705 Var706 Var707 Var708 Var709 Var710 Var711 Var712 Var713 Var714 Var715 Var716 Var717 Var718 Var719 Var720 Var721 Var722 Var723 Var724 Var725 Var726 Var727 Var728 Var729 Var730 Var731 Var732 Var733 Var734 Var735 Var736 Var737 Var738 Var739 Var740 Var741 Var742 Var743 Var744 Var745 Var746 Var747 Var748 Var749 Var750 Var751 Var752 Var753 Var754 Var755 Var756 Var757 Var758 Var759 Var760 Var761 Var762 Var763 Var764 Var765 Var766 Var767 Var768 Var769 Var770 Var771 Var772 Var773 Var774 Var775 Var776 Var777 Var778 Var779 Var780 Var781 Var782 Var783 Var784 Var785 Var786 Var787 Var788 Var789 Var790 Var791 Var792 Var793 Var794 Var795 Var796 Var797 Var798 Var799 Var800 Var801 Var802 Var803 Var804 Var805 Var806 Var807 Var808 Var809 Var810 Var811 Var812 Var813 Var814 Var815 Var816 Var817 Var818 Var819 Var820 Var821 Var822 Var823 Var824 Var825 Var826 Var827 Var828 Var829 Var830 Var831 Var832 Var833 Var834 Var835 Var836 Var837 Var838 Var839 Var840 Var841 Var842 Var843 Var844 Var845 Var846 Var847 Var848 Var849 ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ _____ _____ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469 44469
L=numel(t1(1,:))
L = 849
t=t1(1,:);
S=t1(2,:);
plot(t,S)
Error using plot
Invalid subscript for Y. A table variable subscript must be a numeric array containing real positive integers, a logical array, a character vector, a string array, a cell array of character vectors,
or a pattern scalar used to match variable names.
f=Fs*(0:(L/2))/L;
Y=fft(S);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
plot(f,P1)
title('Single-Sided Amplitude')
xlabel('f (Hz)')
ylabel('|P1(f)|')

Accepted Answer

Star Strider
Star Strider on 3 Feb 2023
It looks correct to me. I made three changes: indexing into the table and references to it, subtracted the mean from ‘S’ since it has a non-zero offset and the D-C compoonent was hiding the other peaks, and ‘zoomed’ the x-axis of the Fourier transform plot to make the details easier to see.
Fs=1000;
T=1/Fs;
t=readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1284000/t.xlsx');
L=numel(t(1,:));
tv=t{1,:};
S=t{2,:};
plot(tv,S)
f=Fs*(0:(L/2))/L;
Y=fft(S-mean(S)); % Subtract The Mean (D-C Offset) To See The Other Peaks
P2 = abs(Y/L);
P1 = P2(1:fix(L/2)+1);
P1(2:end-1) = 2*P1(2:end-1);
plot(f,P1)
title('Single-Sided Amplitude')
xlabel('f (Hz)')
ylabel('|P1(f)|')
xlim([0 150]) % Optional
With those minor changes, your code appears to do what you want it to do.
.
  4 Comments

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 3 Feb 2023
Fs=1000;
T=1/Fs;
t1 = readtable('t.xlsx');
L = width(t1);
t = t1{1,:};
S = t1{2,:};
plot(t,S)
f=Fs*(0:(L/2))/L;
Y = fft(S - mean(S));
P2 = abs(Y/L);
P1 = P2(1:floor(L/2+1));
P1(2:end-1) = 2*P1(2:end-1);
plot(f,P1)
title('Single-Sided Amplitude')
xlabel('f (Hz)')
ylabel('|P1(f)|')
  1 Comment
uzzi
uzzi on 3 Feb 2023
Thank you for the answer. I don't know how to interpret the diagram. Do you have any ideas?

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!