MATLAB Answers

Prolemn with close Matlab folder

2 views (last 30 days)
thu nguyen
thu nguyen on 5 Nov 2019
Commented: thu nguyen on 6 Nov 2019
Hi everyone,
I have a problemn like the picture. When I use Matlab program, I try to rename the folder containing *.mat files. Although, all files had closed, I can not rename it. Can you help me? Thanks a lot!
Thu Nguyen
folder_problemn.PNG

  3 Comments

galaxy
galaxy on 5 Nov 2019
Because another program still use this folder or files in folder, so you can not modify it's name.
Maybe, you restart Matlab, it will be OK.
If you do not know which program using , please restart machine.
galaxy
galaxy on 5 Nov 2019
Your name same my younger sister name.
Which university do you learning ???
Walter Roberson
Walter Roberson on 5 Nov 2019
You cannot typically cannot rename a folder that is your current directory.

Sign in to comment.

Accepted Answer

galaxy
galaxy on 6 Nov 2019
Edited: galaxy on 6 Nov 2019
You need to check movefile function which you used is OK or NG
  1. Original, after cd command.
2. after use movefile
3. after use rmdir
Because you jump to testpatient folder, so you can use rmdir('Opt_data') only.
If you still problem, if you can, please send me the source code, I want to see it

  11 Comments

Show 8 older comments
thu nguyen
thu nguyen on 6 Nov 2019
I appreciate all your helps. I will try on Matlab 2015a.
By the way, if you can, you can tell me where you work.
galaxy
galaxy on 6 Nov 2019
Currently, I am working in Japan.
When you change to 2015a, only 1 problem will occur. From 2013b, matlab did not support matlabpool function. So you need to comment (line 49 - 51 of start_optimization.m) or change as you want.
=> I commented, and your script ran perfectly.
thu nguyen
thu nguyen on 6 Nov 2019
Now, I see that why you call me "Thu san".
I will try your recommendation. If I have any problem, I will send you question.
Thank you so much!

Sign in to comment.

More Answers (5)

thu nguyen
thu nguyen on 5 Nov 2019
Thank you for all your answers. When I renamed, I tried many ways such as
1/ Closed all programs
2/ Change current folder
But it did not effect.
Only I restart Matlab, I could rename the folder. But it is not convinient.
By the way, I work at University of Science, Ho Chi Minh city, Vietnam.
Thu Nguyen

  2 Comments

galaxy
galaxy on 5 Nov 2019
In Matlab, you can modify any folder's name if this folder is contained in Matlab path.
In this case, maybe you rename after you used files or addpath to this folder. So you can not.
You can check Matlab path by
>> path
Besides, nice to meet you. I am Vietnamese too.
It you have any problems about Matlab, you can ask me
Image Analyst
Image Analyst on 5 Nov 2019
Did you have Windows File Explorer open viewing that folder? That might prevent renaming.

Sign in to comment.


thu nguyen
thu nguyen on 5 Nov 2019
Thank to all helps!
Nice to meet you, galaxy. It is so great!
I checked your recommendations, but it did not work.
folder_problemn.PNG
And I also checked the Windows File Explorer open viewing that folder. I closed all, except the window to rename the folder. But it also did not work.

  1 Comment

galaxy
galaxy on 5 Nov 2019
I can’t believe that happened.
Please close all application, folder in your machine and tell me procedure you use MATLAB.
ex:
  • open MATLAB
3.PNG
  • rename of New Folder to xxx
  • error occur

Sign in to comment.


thu nguyen
thu nguyen on 5 Nov 2019
path.png
These are the paths in Matlab.

  4 Comments

Show 1 older comment
thu nguyen
thu nguyen on 6 Nov 2019
I used
restoredefaultpath
rehash toolboxcache
and the default Matlab come back.
But I don't understand why I add the directories to the bottom of the path because I want to these functions in these directories being the first.
Walter Roberson
Walter Roberson on 6 Nov 2019
Whenever you add functions to the top of the path, they take priority over any built-in functions by the same name. That can lead to problems for a variety of programs, not just when you are using that particular software. If you add to the bottom of the path, then any function names that are duplicated would only be a problem running that particular software.
thu nguyen
thu nguyen on 6 Nov 2019
Thank you for your explaination to me. I will notice that.

Sign in to comment.


thu nguyen
thu nguyen on 5 Nov 2019
Thank for your consideration.
The procedure as following,
Step 1:
Open Matlab program
cd (‘D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\RunOpt’)
Step 2:
Run the *.m file (run_opt.m)
The result of this step is the data which is in folder Opt_data and some figures.
Step 3:
Change the name of folder Opt_data to other name so that I can restart the procedure.
In this step, the paths of Matlab
And Current folder in Matlab is
D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\RunOpt
While, the folder I need to rename in the path is
‘D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient\Opt_data’
When I tried to rename the folders by closing all windows, except Matlab program because I need it to run again, I can not
.
rename.
So I must close the Matlab, then I rename. After that, I open Matlab and restart the procedure. It is time consuming.

  7 Comments

Show 4 older comments
galaxy
galaxy on 6 Nov 2019
You need to put full path of folder.
thu nguyen
thu nguyen on 6 Nov 2019
I also checked your recommendation. It also doesn't work.
rmdir('D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient\Opt_data')
??? Error using ==> rmdir
No directories were removed.
galaxy
galaxy on 6 Nov 2019
You received this error because folder not empty.
You need to use rmdir after you use movefile, when Opt_data was empty,

Sign in to comment.


thu nguyen
thu nguyen on 6 Nov 2019
I checked your recommendation, but the result as following
>> cd ('D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient')
movefile('Opt_data','Opt_data_0')
>> rmdir('D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient\Opt_data')
??? Error using ==> rmdir
No directories were removed.

  2 Comments

galaxy
galaxy on 6 Nov 2019
You use movefile wrong.
You move Opt_data folder to in Opt_data_0 folder.
You need move all files in Opt_data folder only.
You can use as below
cd ('D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient');
movefile('Opt_data\*','Opt_data_0');
rmdir('Opt_data');
thu nguyen
thu nguyen on 6 Nov 2019
I tried your code. The movefile function works, but the rmdir function does not work.
>> cd ('D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient ');
movefile('Opt_data\*','Opt_data_0 ');
rmdir('D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient\Opt_data');
??? Error using ==> rmdir
No directories were removed.

Sign in to comment.

Sign in to answer this question.


Translated by