当前位置:网站首页>Matlab: 文件夹锁定问题的解决
Matlab: 文件夹锁定问题的解决
2022-06-11 21:39:00 【笨牛慢耕】
目录
1. 问题描述
考虑如下这样的Matlab程序,先用addpath将simulink模型所在的文件夹加入路径,然后执行参数初始化,然后再用sim命令调用simulink模型进行仿真(这里仿真的具体内容不是要点,这里仅仅是借这个例子来说明问题)。
close all; clear; clc
addpath('.\simulink');
b = [-2, 6, 3];
a = [3, 0, 2, 1];
[r,p,k] = residue(b,a)
[b,a] = residue(r,p,k)
sim('MyModel',10) % most basic way to simulate with command script.
在模型调试过程中,在每次仿真后,有时会需要对当前仿真用到过的目录或者仿真生成的目录进行操作,比如说移动、更名或者删除等等。
然后我经常发现,有些目录无法进行移动、更名或者删除等操作,用clear命令、close命令等进行workspace清除也不解决问题。很长时间以来,碰到这种问题我唯一能做的就是用最笨的办法:将matlab关掉,进行文件夹操作,然后再重新启动matlab。
2. 解决方案
之前每次操作都是在windows explorer中做,操作被拒绝也不知道什么原因。今天偶然地在Matlab窗口中的文件浏览窗口中对一个这样的文件夹做了一次操作,虽然也被拒绝了,但是matlab弹出了一个信息窗口,终于知道了操作被拒绝的原因,如下图所示:

原来如此。。。simulink这个文件夹被用addpath()命令加入到Matlab路径变量中去了,因此被Matlab锁定,不能进行移动、更名或者删除操作!
原因知道了,那解决对策就很简单了。
addpath()函数的逆操作时rmpath(),在仿真脚本的最后,用rmpath()将simulink从Matlab路径移除,就不会被锁定了。如下所示:
close all; clear; clc
addpath('.\simulink');
...
sim('MyModel',10) % most basic way to simulate with command script.
rmpath('.\simulink');
3. 后记
虽然是一个很trival的问题,但是我被这个问题困扰了很久。今天终于解决了,记录于此,或能有些许参考价值。
当然以上所说的只是Matlab锁定文件夹的一种可能方式。我还碰到过其它的被锁定的情况,改日碰到问题再现并找到解决方案再来追加补充。
边栏推荐
- The same efficiency tool for leading enterprises to promote smart finance. Let's have a quick look?
- servlet获取表单数据
- Redis basic data type (list)
- 剑指Offer 29.顺时针打印矩阵
- 华为设备配置HoVPN
- [Part 14] source code analysis and application details of completionservice class [key]
- Relatively perfect singleton mode
- 238.除自身以外数组的乘积
- 如何创建最简单的 SAP Kyma Function
- Codeforces Round #739 (Div. 3)解题报告
猜你喜欢

servlet获取表单数据

The network connection is normal, but Baidu web page can not be opened and displayed. You can't access this website solution

Add anti debugging function to game or code (application level)

Leetcode-129- sum of numbers from root node to leaf node

LeetCode-110-平衡二叉树

Flutter series: detailed explanation of container layout commonly used in flutter

RPA+低代码助推品牌电商启新创变、重启增长

LabVIEW控制Arduino实现红外测距(进阶篇—6)

apache 本地多端口配置

联调这夜,我把同事打了...
随机推荐
2022-02-28(2)
RPA超自动化 | 农耕记携手云扩加速财务智能化运营
Parker plunger pump pv180r1k1t1nmmc
LeetCode-129-求根节点到叶节点数字之和
如何使用事物码 SAT 查找某个 SAPGUI 屏幕字段对应的后台存储数据库表的名称
[Part 14] source code analysis and application details of completionservice class [key]
Codeworks round 744 (Div. 3) problem solving Report
Add anti debugging function to game or code (application level)
Redis basic data type (set)
LabVIEW controls Arduino to realize infrared ranging (advanced chapter-6)
Test plans and test cases
apache 本地多端口配置
CANN编码的一些报错汇编
Analysis on the development history and market development status of China's system integration industry in 2020 [figure]
[Part 13] source code analysis and application details of completabilefuture class [key]
Flink error: multiple tasks are started, and only one task is executed
一步步把 SAP UI5 应用部署到 SAP BTP Kyma 运行环境中去
Why is rpa+ low code a powerful tool to accelerate the digital transformation of finance?
Bipartite King
Relatively perfect singleton mode