Clear Filters
Clear Filters

Integrating over a step function

4 views (last 30 days)
David Sicic
David Sicic on 26 Oct 2022
Edited: Torsten on 26 Oct 2022
Hello everyone,
I´m currently working on a little program where I read some data from an Ecxel Sheet and plot a cooling curve from it with some mathematical equotions. Until now i have only used one value (scalar) for my power profile P and PC. Now i want to integrate a power profile from an excel sheet, which is not an scalar anymore but rather a step function. My problem is now that i dont know how to finish the code as i dont know how to implement the step function into the integral. I have to plot 2 different curves given from to 2 different results, thats why it is doubled.
Thanks in advance.
the profile is given below, on the left the time in seconds is given and on the right side the Power profile.
% The file should be in the currently used Matlab folder
% Please enter the .xlsx data and the desired measurement (Fit) of the examined chip
values = xlsread('AAA', 'Fit 1');
% The file should be in the currently used Matlab folder
% Please enter the .xlsx data and measurement of the coupled thermoelement
valuesC = xlsread('Kopplung', 'Fit 1');
% Please enter the power profile
PowerValues = xlsread('LeistungImpuls4Chips', 'Chip4_P');
cooling_time = values(:,1)';
Fitted_Curve = values(:,3)';
R_F = values(:,4);
R_F = R_F(~isnan(R_F))';
C_F = values(:,5);
C_F = C_F(~isnan(C_F))';
Tmax = max(values(:,2));
P = @(t) 303,839733;
cooling_timeC = valuesC(:,1)';
Fitted_CurveC = valuesC(:,3)';
R_FC = valuesC(:,4);
R_FC = R_FC(~isnan(R_FC))';
C_FC = valuesC(:,5);
C_FC = C_FC(~isnan(C_FC))';
TmaxC = max(valuesC(:,2));
PC = @(k) 827,2826177;
%Time = values3(:,2)';
%Power = values3(:,1)';
%Calculation of the derived Zth values
dZ_th = @(t) 0;
for v = 1:length(R_F)
dZ_th = @(t) dZ_th(t) + exp(-t / (R_F(v) * C_F(v))) / C_F(v);
end
dZ_thC = @(k) 0;
for l = 1:length(R_FC)
dZ_thC = @(k) dZ_thC(k) + exp(-k / (R_FC(l) * C_FC(l))) / C_FC(l);
end
%Calculation of the temperature curve
T_j_scalar_t = @(t) integral(@(tau) P(tau) .* dZ_th(t - tau), 0, t);
T_j = arrayfun(@(t)T_j_scalar_t(t), cooling_time);
T_j_scalar_tC = @(k) integral(@(lambda) PC(lambda) .* dZ_thC(k - lambda), 0, k);
T_jC = arrayfun(@(k)T_j_scalar_tC(k), cooling_timeC);
%reversing the temperature curve
T_i = (Tmax - T_j);
semilogx(cooling_time, T_i)
hold on
T_iC = (TmaxC - T_jC);
semilogx(cooling_timeC, T_iC)
hold on
T_all = (T_i + T_iC)
semilogx(cooling_time, T_all)
hold on
%Calculation of Zth curve
%Zth_norm = (Tmax - T_j) ./P(cooling_time);
%semilogx(cooling_time, Zth_norm)
%hold on
%Zth2_norm = (Tmax2 - T_j2) ./P(cooling_time2);
%semilogx(cooling_time2, Zth2_norm)
%hold off
xlabel("Time in s");
ylabel("Temperature")
legend('T_i','T_iC','T_all')
  8 Comments
David Sicic
David Sicic on 26 Oct 2022
Edited: David Sicic on 26 Oct 2022
Im getting now quite a big error message
Error using matlab.internal.math.interp1
The sample points must be finite.
Torsten
Torsten on 26 Oct 2022
Edited: Torsten on 26 Oct 2022
Then your vectors t_Excel and/or P_Excel contain NaN, Inf or -Inf values.
Further take care that t_Excel is ordered (either ascending or descending).
Further the interpolation will return NaN if the t-value with which it is called is not in between t_Excel_min and t_Excel_max.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!