I am plotting the derivative of a curve. Getting the y value for maximum peak height of the biggest peak. But when I try to get the x value corresponding to that y value its not giving me any value. Following is the code. Any help would be appreciate
2 次查看(过去 30 天)
显示 更早的评论
a = load('ra1.dat');
x = a(:,1);
y = a(:,2);
y_mov_average = filter(ones(1,50)/50,1,y);
plot(x,y);
hold on
dy = diff(y)./diff(x);
dy_mov_average = filter(ones(1,10)/10,1,dy);
plot(x(2:end),dy_mov_average);
PEAKSID = findpeaks(dy_mov_average);
ID = class(PEAKSID);
PEAKIDCAL = double(max(PEAKSID));
VALUE = find(y==PEAKIDCAL);
xaty = x(VALUE);
A portion of the ra1.dat is pasted below. Its a force distance plot by atomic force microscope.
817 -1.602783
815.8824 -1.604004
814.7649 -1.603394
813.6473 -1.602783
812.5298 -1.602478
811.4122 -1.602173
810.2946 -1.601563
809.1771 -1.601868
808.0595 -1.602478
806.942 -1.601868
805.8244 -1.602478
804.7068 -1.602478
803.5893 -1.602173
802.4717 -1.602478
801.3542 -1.603088
800.2366 -1.603699
799.1191 -1.601868
798.0015 -1.602783
796.8839 -1.603088
795.7664 -1.603394
794.6488 -1.604004
793.5313 -1.603088
792.4137 -1.604309
791.2961 -1.604004
790.1786 -1.603394
789.061 -1.604614
787.9435 -1.604004
786.8259 -1.604919
785.7084 -1.604004
784.5908 -1.603394
783.4732 -1.604309
782.3557 -1.604614
781.2381 -1.604614
780.1205 -1.604004
779.003 -1.60553
777.8854 -1.604309
776.7679 -1.604309
775.6503 -1.604614
774.5328 -1.604004
773.4152 -1.604004
772.2977 -1.604614
771.1801 -1.604919
770.0625 -1.604614
768.9449 -1.60553
767.8274 -1.604309
766.7098 -1.605225
765.5923 -1.606445
764.4747 -1.60675
763.3572 -1.60614
762.2396 -1.60614
761.1221 -1.60553
760.0045 -1.604614
758.887 -1.603394
757.7694 -1.603699
756.6518 -1.604919
755.5342 -1.60553
754.4167 -1.60553
753.2991 -1.604614
752.1816 -1.604919
751.064 -1.605835
749.9465 -1.60553
748.8289 -1.60553
747.7114 -1.60553
746.5938 -1.606445
745.4763 -1.605835
744.3587 -1.60614
743.2411 -1.604919
742.1235 -1.605835
741.006 -1.60553
739.8884 -1.60553
738.7709 -1.60675
737.6533 -1.607056
736.5358 -1.607666
735.4182 -1.607666
734.3007 -1.607056
733.1831 -1.607666
732.0656 -1.606445
730.948 -1.607971
729.8304 -1.607666
728.7128 -1.607056
727.5953 -1.607361
726.4777 -1.608276
725.3602 -1.607056
724.2426 -1.60614
723.1251 -1.608582
722.0075 -1.608887
720.89 -1.609802
719.7724 -1.609192
718.6548 -1.608887
717.5373 -1.608276
716.4197 -1.608582
715.3021 -1.609802
714.1846 -1.608276
713.067 -1.608276
711.9495 -1.609802
710.8319 -1.609497
709.7144 -1.609497
708.5968 -1.609802
707.4792 -1.610107
706.3617 -1.608276
705.2441 -1.608276
704.1266 -1.607666
703.009 -1.608887
701.8914 -1.608276
700.7739 -1.608582
699.6563 -1.608887
698.5388 -1.608582
697.4212 -1.609802
696.3036 -1.609192
695.1861 -1.610107
694.0685 -1.609802
692.951 -1.610107
691.8334 -1.609192
690.7159 -1.609192
689.5983 -1.610107
688.4807 -1.609802
687.3632 -1.609802
686.2456 -1.611023
685.1281 -1.609802
684.0105 -1.610718
682.8929 -1.610107
681.7754 -1.610413
680.6578 -1.609802
679.5403 -1.611633
678.4227 -1.611328
677.3052 -1.610718
676.1876 -1.610718
675.07 -1.611023
673.9525 -1.611328
672.8349 -1.611328
671.7173 -1.613159
670.5998 -1.612244
669.4822 -1.612244
668.3647 -1.612244
667.2471 -1.611633
666.1296 -1.611023
665.012 -1.611938
663.8944 -1.612854
662.7769 -1.613464
661.6593 -1.613159
660.5417 -1.612854
659.4242 -1.61377
658.3066 -1.61377
657.1891 -1.61377
656.0715 -1.613464
654.954 -1.613464
653.8364 -1.611328
652.7189 -1.611938
651.6013 -1.611938
650.4837 -1.611633
649.3661 -1.612549
648.2486 -1.61438
647.131 -1.612854
646.0135 -1.612549
644.8959 -1.613159
643.7784 -1.614075
642.6608 -1.613464
641.5433 -1.612854
640.4257 -1.613464
639.3082 -1.613464
638.1906 -1.612549
637.073 -1.612244
635.9554 -1.613464
634.8379 -1.613159
633.7203 -1.613464
632.6028 -1.61377
631.4852 -1.614075
630.3677 -1.61377
629.2501 -1.614075
628.1326 -1.61438
627.015 -1.615295
625.8975 -1.615906
624.7799 -1.615906
623.6623 -1.61499
622.5447 -1.616211
621.4272 -1.61499
620.3096 -1.61499
619.1921 -1.616211
618.0745 -1.615295
616.957 -1.615601
615.8394 -1.616211
614.7219 -1.615601
613.6043 -1.61499
612.4868 -1.615601
611.3692 -1.617432
610.2516 -1.615906
609.134 -1.615601
608.0165 -1.617126
606.8989 -1.617737
605.7814 -1.617126
604.6638 -1.616821
603.5463 -1.617432
602.4287 -1.617432
601.3112 -1.617737
600.1936 -1.618347
599.076 -1.618347
597.9585 -1.618347
596.8409 -1.618958
595.7233 -1.618347
594.6058 -1.618958
593.4882 -1.618042
592.3707 -1.618652
591.2531 -1.618652
590.1356 -1.618652
589.018 -1.618958
587.9005 -1.618958
586.7829 -1.618958
585.6653 -1.619873
584.5478 -1.620483
0 个评论
采纳的回答
KSSV
2016-10-4
编辑:KSSV
2016-10-4
You can get the position/index of the maximum element from array using max itself. You need not to find the index later.
a = load('ra1.dat');
x = a(:,1);
y = a(:,2);
y_mov_average = filter(ones(1,50)/50,1,y);
plot(x,y);
hold on
dy = diff(y)./diff(x);
dy_mov_average = filter(ones(1,10)/10,1,dy);
plot(x(2:end),dy_mov_average);
PEAKSID = findpeaks(dy_mov_average);
ID = class(PEAKSID);
[PEAKIDCAL,VALUE] = (max(PEAKSID)); % get max and it's index
% VALUE = find(y==PEAKIDCAL);
xaty = x(VALUE);
4 个评论
KSSV
2016-10-4
max gives the maximum..the second cannot be greater. Your first code was not working because, you were equating floating numbers, which you should not.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!