I have several MATLAB scripts, e.g., fun1, fun2,…etc There can have dependency relationships among them. For instance, fun1 can call fun2 and fun2 can call fun3.
In order to remove unnecessary variables, should I put “clear all;” at the head of every functions.
function x1 = fun1(input1)
clear all;
...
Will this cause any potential issue, such as removing useful variables?
All
clear allwill do in that context, is to remove your input variables. When you are within a function, the only variables that function sees are the variables passed into the function. So, you will find that to be not a particularly helpful pattern.