MATLAB: Passing the variable is fast or creating the variable new variable is fast

variables

Lets take an exapmle:
n=100; target to generate s=zeros(n,n);
should I pass this s or generate locally in the function?
I have to run the function, let say 10000 iteration

Best Answer

Passing the variable is better , see preallocation which enhances speed and efficiency