Azzera filtri
Azzera filtri

How do I get my code to output each output value with the different input values. error message is Out of memory. The likely cause is an infinite recursion within the program.

1 visualizzazione (ultimi 30 giorni)
here is the code and what is in the command window:
function f = swamee_jain_friction_factor(Re, epsilon_over_D)
term1 = 5.74/(Re^0.9) + abs(epsilon_over_D)/ 3.7;
term2 = (log10(term1))^2;
f = 0.025 / (term2);
% Define Reynolds numbers and epsilon/D values
Re_values = [10000, 100000, 1000000, 10000000];
epsilon_over_D_values = [0.00001, 0.0001, 0.001,0.01];
% Initialize an array to store calculated friction factors
num_Re = length(Re_values);
num_epsilon_over_D = length(epsilon_over_D_values);
friction_factors = zeros(num_Re, num_epsilon_over_D);
% Calculate friction factors for different Reynolds numbers and epsilon/D values
for i = 1:num_Re
for j = 1:num_epsilon_over_D
Re = Re_values(i);
epsilon_over_D = epsilon_over_D_values(j);
friction_factors(i, j) = swamee_jain_friction_factor(Re, epsilon_over_D);
end
end
command window
swamee_jain_friction_factor(10000,0.001)
Out of memory. The likely cause is an infinite recursion within the program.
Error in swamee_jain_friction_factor (line 22)
friction_factors(i, j) = swamee_jain_friction_factor(Re, epsilon_over_D);

Risposte (1)

Walter Roberson
Walter Roberson il 5 Nov 2023
% Define Reynolds numbers and epsilon/D values
Re_values = [10000, 100000, 1000000, 10000000];
epsilon_over_D_values = [0.00001, 0.0001, 0.001,0.01];
% Initialize an array to store calculated friction factors
num_Re = length(Re_values);
num_epsilon_over_D = length(epsilon_over_D_values);
friction_factors = zeros(num_Re, num_epsilon_over_D);
% Calculate friction factors for different Reynolds numbers and epsilon/D values
for i = 1:num_Re
for j = 1:num_epsilon_over_D
Re = Re_values(i);
epsilon_over_D = epsilon_over_D_values(j);
friction_factors(i, j) = swamee_jain_friction_factor(Re, epsilon_over_D);
end
end
surf(Re_values, epsilon_over_D_values, friction_factors, 'edgecolor', 'none');
function f = swamee_jain_friction_factor(Re, epsilon_over_D)
term1 = 5.74/(Re^0.9) + abs(epsilon_over_D)/ 3.7;
term2 = (log10(term1))^2;
f = 0.025 / (term2);
end

Categorie

Scopri di più su Fluid Dynamics in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by