I am trying to use a function to develop my variables for the rest of my code since its used multiple times. here is an example. try to keep it simple since I just recently started learning MATLAB. basically want De and RE to be used in the function below.
function single_data (~,~)p = input('density/kg/m^3 ');e = input('surface roughness/m ');D = input('diameter/m ');Q = input('volumetric flowrate/m^3/s ');u = input('viscosity/pa/s ');A = input('cross-sectional aream/m^2 ');De = e/D;syms seqn = (p*D*Q)/(u*A) == s;RE = vpasolve(eqn,s);f3 = figure(3);FA = uicontrol(f3,'Style','togglebutton','callback', @frictionFA,'String','automated(vpasolve) ','Position',[20 20 200 30]);FBS = uicontrol(f3,'Style','togglebutton','callback', @frictionFBS,'String','bisection method','Position',[20 50 200 30]);FNR = uicontrol(f3,'Style','togglebutton','callback', @frictionFNR,'String','Newton Rhapson Method ','Position',[20 80 200 30]);endfunction frictionFA (~,~)syms fA eqntwo = 1/sqrt(fA) == -2*log((De)/(3.7)+(2.51)/(RE*sqrt(fA)));AS = vpasolve(eqntwo,fA);fprint(AS)end
Best Answer