% Function for speed
function fv = project_1 (v)v = [2 3]; % Speed values
g = 9.81; % Gravity
d = .05; % Distance to Mixing System Output
ki = 2.4; % Flow Obstruction Factor in the pipe
D = .0254; % Hose diameter
pe = 746; % Electrical power of the pump
L = 2.2; % Length
ipsilon = .00000101; % Kinematic Viscosity
ro = 997; % Water Density
epsilon = .00001; % Roughness
Re = (v * D)/ ipsilon; % Reynolds Number
f = 1.325./ (log(epsilon /(3.7 * D) + 5.74./(Re.^.9 )).^ 2; % Coefficient of friction
hf = (L * f.*v.^2) / (2 * g * D) + (ki * v.^2 / (2 * g)); % Friction loss
A = 3.141592 * (D^2 / 4); % Cross sectional area
Q = v.* A; % Pipe flow
hb = w./ (Q * ro * g); % Energy gain per pump
fv = ((v.^2) / (2 * g)) + d + hf - hb; % Speed function
% Secant method
i = 2;err = .00005;while abs(fv(i)) > err v(i+1) = v(i)-(fv(i)*(v(i)-v(i-1)))/(fv(i)-fv(i-1)) i=i+1; fv(i) = project_1 (v); if i > 100 break endend
I'm trying to apply the secant method to the function defined in fv, but I keep getting the out of memory message.
Out of memory. The likely cause is an infinite recursion within the program.
Error in project_1 (line 37)
fv(i) = project_1 (v);
Best Answer