Question: what is the difference between function and script in matlab?
Answer: Scripts are m-files containing MATLAB statements. ... The biggest difference between scripts and functions is that functions have input and output parameters. Script files can only operate on the variables that are hard-coded into their m-file. As you can see, functions much more flexible.