当前位置:网站首页>Matlab file path

Matlab file path

2022-07-28 08:30:00 Kaizhi~

        generally speaking , The function file that can be called by the script file must be under the same file path , So in general MATLAB Projects are a folder , It stores all the .m file . But in fact , The function files that script files can call also include private Private functions in folders . As shown in the figure below ,Base.m and nua.m The file is a script file ,x.m、y.m、z.m For function file .Base.m File is callable by default y.m and x.m file , Cannot call new In folder z.m file .

 Insert picture description here

        If in Base.m An attempt was made to call z.m file , The following prompt appears in the command line window :

 Insert picture description here
        The former means to switch to z.m The folder where the file is located to continue running , Of course, even if you choose this option, it will not work normally in Base.m Call in file z.m file , Because at this time Base.m The file is not in the current folder , So it can't run . Only the latter , take z.m Add the file to the path ( similar keil Add the file path ), In order to operate normally . The current folder window is shown in the following figure , You can see ,z.m The folder is “ Lighten up ”. here ,Base.m、y.m、z.m、nua.m Can call each other , Of course ,z.m、nua.m Cannot call through this method private In folder x.m file .

 Insert picture description here

        The method of adding a path is to add it after running and reporting an error , You can also right-click in the current folder window and select “ Add to path ”, The effect is the same .

        View the method of added path , You can click Set path in the Home tab .

 Insert picture description here

        The following window pops up , On the right is the added path ,MATLAB If the corresponding function cannot be found at runtime , Will search in turn .
 Insert picture description here

原网站

版权声明
本文为[Kaizhi~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/197/202207131457501966.html