Creating a Function file with multiple user inputs
Show older comments
So I'm creating a function file that is to be used in multiple root finding methods, the code is already created for those methods however the previous function file had only one variable. The new function is the colebrook equation. I'm suppose to leave this in the most general for so the user can input the known variables. I'm having issues getting the function file to run with the user inputs. I've tried it multiple ways and nothing seems to be working. I have very little experience in MATlab. Please help!!
function f=f2(m1)
e=input('What is the roughness of pipe(m)?');
d=input('What is the diameter of pipe(m)?');
p=input('What is the density of the fluid(kg/m^3)?');
v=input('What is the velocity of the fluid(m/s)?');
u=1.6*10^-4;
r=(p*v*d)/u;
f=-2*log10((e/3.7*d)+(2.51/r*sqrt(m1)))-(1/sqrt(m1));
Answers (1)
Joseph Cheng
on 25 Mar 2014
Edited: Joseph Cheng
on 25 Mar 2014
0 votes
What is the error? The only error i get are that xl and xu are not defined but that is an issue in the falseposition.m file. You will have to define xl and xu if not already done so before you can use it in the f2() function. f2 is working fine Matlab wise, i have not checked the validity of the math.
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!