Why all the code in a MATLAB program are just functions
Show older comments
Hello,
I have a downloaded code which is all functions, and when I run it it (F5) it works.
The code is a GUI which execute image analysis functions.
When I contract all the function drop-downs (with Ctrl + "," ), all the code is based in funtions, there is no one no-function code, and it run correctly anyway when I execute it.
I don't understand that all the code runs without any no-function code, which in my understanding it would be the necessary for to run the functions and the code.
Thank you very much.
Josep
2 Comments
Rik
on 6 Jul 2021
When you run the function with F5 it will run the first function in the file (technically there are exceptions, but let's not focus on those now).
Apparently that creates a figure with some interactive elements. When you interact with such elements, those will have callback functions. That means that you are actually calling one of those internal functions when you click on a button.
It therefore makes perfect sense that there are only functions: you ran the function that created the figure and the elements, and interacting with an element will call a specific function.
Did you do a basic Matlab tutorial? Do you have a specific question?
Josep Llobet
on 6 Jul 2021
Accepted Answer
More Answers (0)
Categories
Find more on Call Python from MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!