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)
.