Creating a Function file with multiple user inputs
显示 更早的评论
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));
回答(1 个)
Joseph Cheng
2014-3-25
编辑:Joseph Cheng
2014-3-25
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!