Findpeaks from the excel data graph
5 次查看(过去 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!