Remove the slprj folder programmatically
182 ビュー (過去 30 日間)
古いコメントを表示
There is an 'slprj' in the working directory that is from another Simulink version. Consequently, I receive the error
'The existing Simulink code generation folder in the current folder was created for a different version of MathWorks products. This project folder is not compatible with the current version. To continue you must manually remove the slprj folder and any generated code files it contains.'
when trying to compile my model. However, I do not want to manually remove the folder each time. The programmatic approach via
rmdir('slprj')
from the MATLAB command line also issues an error.
So how can I programmatically remove the 'slprj' folder?
9 件のコメント
回答 (3 件)
Sean de Wolski
2018 年 11 月 21 日
What about with the 's' option
rmdir('slprj', 's')
2 件のコメント
Gordon Lai
2020 年 4 月 2 日
The full path version of this worked for me as 'slprj' is not empty (nor is it usually).
Note: I first added it and subfolders to the MATLAB path, using
addpath(genpath(pwd))
(unsure if that is necessary)
Sean de Wolski
2020 年 4 月 2 日
編集済み: Sean de Wolski
2020 年 4 月 2 日
Typically if you're calling addpath/genpath, you should be using a project. This also lets you customize code generation settings at a project level.
Jan
2018 年 11 月 21 日
編集済み: Jan
2018 年 11 月 21 日
This does not solve the problem, but helps to identify the problem: Catch the error message:
[status, msg] = rmdir('slprj')
if status ~= 1
fprintf(2, '%s\n', msg);
end
By the way, of course you can use absolute path names even on different platforms. This does not mean a hard coded path name, but that you do not rely on the current directory to be, what you expect. Remember that each timer and GUI callback can use cd to change the current directory, and rmdir('slprj') might access an unexpected folder. Better:
baseFolder = cd; % Or even better: define it with a meaningful folder
[status, msg] = rmdir(fullfile(baseFolder, 'slprj'))
if status ~= 1
fprintf(2, 'Folder: %s\nProblem: %s\n', ...
fullfile(baseFolder, 'slprj'), msg);
end
Now the error message should be more useful.
4 件のコメント
Jan
2018 年 11 月 29 日
The next question: What does "There is an 'slprj' in the working directory that is from another Simulink version" mean? Is "the other Simulink version" still running?
Bonpland
2018 年 11 月 29 日
1 件のコメント
Jan
2018 年 11 月 29 日
Please do not post a pseudo-answer only to bump your question. This wastes the time of all readers. This is the public forum. If you want MathWorks to react to your question, contact them directly using the "Contact Us" link on top of this page.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!