Findpeaks from the excel data graph
조회 수: 3 (최근 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)
댓글 수: 0
채택된 답변
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')
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)
.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!