private folder does not work with live scripts

조회 수: 6 (최근 30일)
Brian
Brian 2025년 6월 20일
댓글: Stephen23 2025년 6월 23일
Live scripts don't seem to support running functions inside a private folder as of R2024B, whereas normal scripts and functions do. An easy workaround is to rename the folder to something else and add it to path. I'm not sure if this is the right place for feedback, but would it be possible to fix this in future releases?
See attached for a minimal reproducible example.

답변 (1개)

Meet
Meet 2025년 6월 23일
편집: Meet 2025년 6월 23일
Hi Brian,
I was able to reproduce the issue on my end using the example you provided. Since both the "mre.mlx" and "mre2.m" scripts are at the same level in the private folder, I could access the "foo" function within the folder.
Private functions are useful when you want to limit a function's scope. You mark a function as private by placing it in a subfolder named "private." This makes the function accessible only to scripts and functions in the folder directly above the private subfolder.
For more information on "private" functions, you could refer to this MathWorks documentation:

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by