MATLAB: How to use one variable between two function variable I want to use single variable between two function that created by me. so how can i do this ?? Best Answer Dipten, you can simply pass those variables as input and output parameters between your functions. E.g. function val1 = my_fun1(inp1) ... inp = ... v2 = my_fun2(inp); % call my_fun2 with parameter inp end function val2 = my_fun2(inp2) % in this case inp2 = inp ... % do some computations val2 = ... % and return val2 to the calling function end Related SolutionsMATLAB: Switch between subfunctions use switch or if..end, e.g.:function funmain(..., p1) function funs1() ... end function funs2() ... end ... % 1 or 2 variantend% 1 variant switch p1 case case_expr1 ... = funs1(); case case_expr2 ... = funs2(); end% 2 variant if p1 == expr (or strcmp(p1,expr)...) ... = funs1(); else ... = funs1(); end MATLAB: Operation using *.m file make hthresh.m and sthresh.m as function filesfunction val1 = hthresh()function val2 = sthresh()and use the below code in another .m fileval1 = hthresh();val2 = sthresh();avg = (val1+val2)/2; Related QuestionVarargout – How to realize function callFor-loop questionFunction variables not saved to workspaceHow to normalise corresponding columns in several matrices to values between -1 and 1
Best Answer