Good day. Please what is the difference between a script file and a function file, and in which case or situation is either one preferred above the other?

1 Ansicht (letzte 30 Tage)
There are some programs that can be written in both script and function file. So I want to know which is more preferable. I want to the situation when I need to choose one above the other.

Antworten (1)

ES
ES am 16 Mär. 2018
Generally Functions are better because they have defined interfaces do not interfere with base workspace unless explicitly coded, and are faster (because they are not interpreted everytime they are run).
But the answer really depends on your use case.
https://in.mathworks.com/help/matlab/matlab_prog/scripts-and-functions.html

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by