Obtaining max value from cyclic data
17 ビュー (過去 30 日間)
古いコメントを表示
Hello, I need to obtain the max value of temperature from a cyclic (100 cycles) data. I have tried the following method:
% Start of code
temp_max(:,1) = GetMaxValue(temp,step,3)
function [out] = GetMaxValue(in,step,step_1)
k = 1;
for i = 2: length(temp)
if step(i) == step_1
out(k) = max(in(i))
k = k + 1;
end
end
end
% end of code
temp is the variable with temperature values and step is the variable of the step numbers. With this code, I am only getting all the values of step 3 as it has nothing to compare the max value against.
Kindly find attached for the excel file with the data. I would request you to help me solve the problem.
Thanks,
Goutham
2 件のコメント
Ganesh
2024 年 1 月 17 日
Do you intend to obtain the maximum temperature from all the data, i.e. the max value of the third column? Or do you intend to obtain the maximum temperature for a particular value of step?
採用された回答
Dyuman Joshi
2024 年 1 月 17 日
移動済み: Dyuman Joshi
2024 年 1 月 17 日
For each cycle, finding the maximum of the temperatures corresponding to the step == 3;
%Read the data
T = readtable('Reference.xlsx')
%Values that satisfy the condition
idx = T.step == 3;
%Finding groups accordingly
[grps, cycnum] = findgroups(T.CycleNumber(idx));
%Compute maximum temperature for each group
Temp_max = accumarray(grps, T.temp(idx), [], @max);
%Cycle number and corresponding Max temperature for step value of 3
out = [cycnum Temp_max]
その他の回答 (1 件)
Mathieu NOE
2024 年 1 月 17 日
hello
I don't understand your logic ... why do we need to make comparisons with anotehr result ( With this code, I am only getting all the values of step 3 as it has nothing to compare the max value against. )
here's a simple code that will generate two plots
- first one is simply to display all temp curves (overlaid) for all cycles
- second one will display the max temp of each cycle vs cycle number


hope it helps
data = readmatrix('Reference.xlsx'); % step / Cycle Number / temp
Cycle_Number = data(:,2);
temp = data(:,3);
CN = unique(Cycle_Number); % get unique values of cycles
% overlay plot temp (for all cycles)
figure
hold on
for k = 1:numel(CN)
ii = Cycle_Number==CN(k); % select data for cycle number = k
max_temp(k) = max(temp(ii)); % store max temp of k th cycle
plot(temp(ii))
end
% plot max_temp vs cycle number
figure
plot(CN,max_temp)
title('Max Temperature ')
xlabel('Cycle#')
ylabel('Temp')
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!