how to do functions without file ?

조회 수: 33 (최근 30일)
Omar Keele
Omar Keele 2021년 2월 13일
답변: Reshma Nerella 2021년 2월 18일
So there is no such functions (like in R) where you can define
myfunction(a,b,c)
do this (while for loops)
do this (do priniting, do whatever you want)
do for loops again, enjoy your life
return something
without putting it in another file, I can put all my functions in a file but I need him to recognize which functions I am calling by its name, I don't want to make a file for each function, it s going to be messy.

답변 (1개)

Reshma Nerella
Reshma Nerella 2021년 2월 18일
Hi,
In MATLAB, you can define multiple functions in the same file.
The first function in the file is called main function, all the other functions are local functions.
Local functions can only be called from main function in the file, whereas main function can be called from anywhere.
For more information, refer to the documentation page of local functions.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by