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!