Random exponential function between two values
8 views (last 30 days)
Hello everyone! I’m trying to create a random vector with a maximum value of xmax_out = 65 and a minimum value of xmin_out = 16. This vector. However, I would like this vector to have an exponential shape, as shown, because I want to simulate the temperature that decreases in contact with a hot fluid to be cooled.
As you can see: I would like the temperature at time 0 (therefore origin of the x axis) to be equal xmax_out while at time t the temperature reaches the xmin_out value. In the project the cooling time is about 50 min.
I tried to use the following code to generate a decreasing random vector, but unfortunately it is linear.
% Temperature range
n = 50; % Length of time [min]
xmin_out = 16 + 273.15; % Minimum outlet temperature [K]
xmax_out = 65 + 273.15; % Maximum outlet temperature [K]
% Random Vector of temperature:
T_out = sort((xmax_out-xmin_out)*rand(n,1)+xmin_out, "descend");