Borrar filtros
Borrar filtros

Obtaining max value from cyclic data

5 visualizaciones (últimos 30 días)
Goutham
Goutham el 17 de En. de 2024
Comentada: Dyuman Joshi el 17 de En. de 2024
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 comentarios
Ganesh
Ganesh el 17 de En. de 2024
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?
Goutham
Goutham el 17 de En. de 2024
Hello Ganesh,
The attached file consists of 100 cycles worth of test data. I am interested in obtaining the maximum value of temperature (3rd column) at each of those 100 cycles when the step is 3.
Thanks

Iniciar sesión para comentar.

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 17 de En. de 2024
Movida: Dyuman Joshi el 17 de En. de 2024
For each cycle, finding the maximum of the temperatures corresponding to the step == 3;
%Read the data
T = readtable('Reference.xlsx')
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
T = 296017×3 table
step CycleNumber temp ____ ___________ ______ 0 0 23.941 1 0 24.17 1 0 24.17 1 0 24.17 1 0 24.146 1 0 24.146 1 0 24.146 1 0 24.146 1 0 24.146 1 0 24.146 1 0 24.146 1 0 24.146 1 0 24.146 1 0 24.13 1 0 24.185 1 0 24.185
%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]
out = 100×2
1.0000 28.9651 2.0000 28.9178 3.0000 28.7285 4.0000 28.7758 5.0000 28.7522 6.0000 28.8626 7.0000 28.8626 8.0000 28.8941 9.0000 29.0598 10.0000 28.8784
  2 comentarios
Goutham
Goutham el 17 de En. de 2024
Thank you for response. It works perfectly.
Dyuman Joshi
Dyuman Joshi el 17 de En. de 2024
You're welcome!

Iniciar sesión para comentar.

Más respuestas (1)

Mathieu NOE
Mathieu NOE el 17 de En. de 2024
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')
  1 comentario
Goutham
Goutham el 17 de En. de 2024
Sorry for not making it clear. But I have got the solution from other colleagues. Thanks for your response.

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by