Findpeaks from the excel data graph

4 次查看(过去 30 天)
Hello Everyone,
I am trying to find the peak from the certain range on my x axis but its not working and giving me the error "Arrayindisices must be positive intergers or logical values".I am atatching the code and excel file as follow.Any help would be appreciated. Thanks in advance.
clc
Data = xlsread('test.xlsx');
%% Step 2 data
x2 =Data(655:8466,6); % Sample temprature
y2 =Data(655:8466,3); % Umsubstracted temprature
figure
plot(x2,y2);
set(gca,'ydir', 'reverse')
title('Step 2 Data')
hold on
%% Peak for step 2
J = x2(x2>90 & x2<120);
[pks, locs] = findpeaks((x2(J)),'Npeaks',1)

采纳的回答

Star Strider
Star Strider 2021-5-27
To create a logical vector for ‘J’, just do:
J = (x2>90 & x2<120);
Then the reference to it works correctly.
However there are no peaks in that region (at least that findpeaks identifies as peaks).
% C1 = readcell('https://www.mathworks.com/matlabcentral/answers/uploaded_files/632270/test123.xlsx');
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/632270/test123.xlsx','VariableNamingRule','preserve')
T1 = 24689×9 table
Var1 Time Unsubtracted Baseline Program Sample Approx. Heat Flow Uncorrected ____ ________ ____________ ________ _______ ______ _______ _________ ___________ NaN 0 -1.3255 0 50 50.062 0 1 -86.659 NaN 0.001667 -1.3257 0 50 50.062 0 1 -86.66 NaN 0.003333 -1.3258 0 50 50.062 0 1 -86.66 NaN 0.005 -1.326 0 50 50.062 0 1 -86.66 NaN 0.006667 -1.326 0 50 50.066 0 1 -86.66 NaN 0.008333 -1.3262 0 50 50.066 0 1 -86.66 NaN 0.01 -1.3265 0 50 50.062 0 1 -86.66 NaN 0.011667 -1.3266 0 50 50.062 0 1 -86.661 NaN 0.013333 -1.3265 0 50 50.062 0 1 -86.66 NaN 0.015 -1.3267 0 50 50.062 0 1 -86.661 NaN 0.016667 -1.3268 0 50 50.066 0 1 -86.661 NaN 0.018333 -1.3269 0 50 50.066 0 1 -86.661 NaN 0.02 -1.3272 0 50 50.066 0 1 -86.661 NaN 0.021667 -1.3274 0 50 50.062 0 1 -86.661 NaN 0.023333 -1.3275 0 50 50.066 0 1 -86.662 NaN 0.025 -1.3275 0 50 50.066 0 1 -86.662
x2 = T1{655:8466,6}; % Sample temprature
y2 = T1{655:8466,3}; % Umsubstracted temprature
figure
plot(x2,y2);
set(gca,'ydir', 'reverse')
title('Step 2 Data')
hold on
%% Peak for step 2
J = (x2>90 & x2<120);
[pks, locs] = findpeaks((x2(J))),'Npeaks',1)
pks = 0×1 empty double column vector locs = 0×1 empty double column vector
.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by