필터 지우기
필터 지우기

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 (최근 30일)
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);

답변 (1개)

Walter Roberson
Walter Roberson 2023년 11월 5일
% 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

카테고리

Help CenterFile Exchange에서 Fluid Dynamics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by