Cannot save a Matlab file

조회 수: 279 (최근 30일)
MiauMiau
MiauMiau 2013년 2월 2일
댓글: Andreas Schnell 2023년 11월 20일
Hi
I know this is not tech support, but since I have updated Matlab to 2012b I experience having lots of problems, so maybe you have some tipps..
So, I have the exact same problem some user posted earlier:
>>I create a new m-file and want to "save it as..." it does not change its name from "untitled" in the Editor and the little star telling i is unsaved does not disapear"<<
..? Any advice? Would be much appreciated
  댓글 수: 7
Jan
Jan 2017년 8월 3일
@Aniruddha Nandi: And it is a really good idea, that you are not allowed to create files in C:\Program File\Matlab\R2016a\bin. You could overwrite important Matlab functions otherwise and even the security concept for the virus protection would be perforated.
Dubravka
Dubravka 2023년 11월 5일
Where Matlab automatically switches me to save the document, I cannot save the document. But I solved it by opening a new folder on the desktop and I save all the programs there without any problems

댓글을 달려면 로그인하십시오.

채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 2월 2일
The reason you are probably seeing this is that your MATLABs current path is somewhere in Program Files where MATLAB has no write permissions. Confirm by: >> pwd
Navigate to some folder where you have write permissions, desktop or some documents folder and try to save your file, it should work fine.
If you have to - have to save it in the program files folder, then launch MATLAB as an administrator, if you have the permissions, by right click MATLAB icon and launch as admin.
  댓글 수: 5
Walter Roberson
Walter Roberson 2020년 10월 12일
편집: Image Analyst 2020년 10월 12일
Szabolcs, what happens if you try to save the file into tempdir() ?
filename = fullfile(tempdir(), 'test.jpg');
testimg = imread('cameraman.tif');
imwrite(testimg, filename);
Does the above work?
If it does, then the problem is that you do not have write permission to the directory you are trying to write to, or the directory does not exist.
Qahraman
Qahraman 2022년 8월 19일
Thanks a lot

댓글을 달려면 로그인하십시오.

추가 답변 (13개)

Shawn
Shawn 2014년 2월 21일
Try launching MATLAB with administrator permission and save the file. I had the same problem and fixed successfully with this. How come MATLAB application does not notify anything about this problem
  댓글 수: 6
Walter Roberson
Walter Roberson 2018년 10월 15일
In MS Windows, right click on the MATLAB icon, and select Run As Administrator
Image Analyst
Image Analyst 2018년 10월 15일
Again, this is not the preferred solution. The preferred solution is to just save your m-files in a folder where you have permission to write to. One place you DO NOT have permission to write to is anywhere under the Program Files folder.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2013년 2월 2일
What do you mean "it does not change its name from "untitled""? You have to do that. You type in the name you want. I just did it to prove to myself it works. I created a new script. I typed in "delete_me" for the filename and I clicked the save button, and it worked just fine.
Or do you mean you tried to type over the name "untitled.m" and no characters appeared in the edit field. No matter how much you type, character just did not appear, and so they did not replace untitled.m?
  댓글 수: 3
Image Analyst
Image Analyst 2013년 2월 3일
Are you using Windows 7? If so, click the Start button. Then in the "Search programs and files" edit field, type in PSR. Then click psr.exe when you see it. Then tell it to record what you do in MATLAB. Stop the recording and upload the zip file to your favorite web site. Tell us where you uploaded it to. Then we will have a series of screenshots where we can observe your operations.
umer farooqfast
umer farooqfast 2016년 9월 17일
i had the same problem but try to relaunch Matlab again and again it will work..

댓글을 달려면 로그인하십시오.


Amani
Amani 2013년 11월 6일
I have the same problem , I cannot save a file to the place where I have a permission to do so what should I do ?
thanks
  댓글 수: 5
Naveen Gowdayyanadoddi
Naveen Gowdayyanadoddi 2013년 12월 18일
편집: Walter Roberson 2015년 8월 27일
Hi:
Even I am facing the same problem. Here is the piece of code that I wanted to save in a new file.
--------------------------------------------------
function mjd = GpsTimeToMjd(gpsTime)
%Account for the UTC leap second offsets
utcLeapSeconds = 16; % as of July 2012
mjd = (gpsTime.weekCycles * 1024 + gpsTime.week) * 7 + (gpsTime.seconds - utcLeapSeconds) / 86400;
--------------------------------------------------
It was fine until day before yesterday. I don't know what changes causing this problem.
Please help.
Image Analyst
Image Analyst 2013년 12월 18일
Same problem will mean the same answers/responses. Basically you don't have, or no longer have, permission to write there.

댓글을 달려면 로그인하십시오.


Ryan Shrott
Ryan Shrott 2015년 8월 27일
This is a very annoying bug...I cannot save my work

Jesse Lopez
Jesse Lopez 2016년 6월 30일
So this exact problem happened to me but i was able to save my work. Here is what I did:
Opened up WordPad and copy/pasted all my script so it keeps my indentations. Closed MATLAB. Then I reopened MATLAB and IMMEDIATELY changed my current folder to documents WITHOUT trying to save. Pasted my script(from WordPAd) into a new script file and I was able to save.
I think after the first time you you try to save somewhere you don't have permission MATLAB blocks you from saving even if you change your folder. One thing you can also try in MATLAB is typing
clear all
in the command window and pressing enter. That might allow you save. What I did worked though.
  댓글 수: 1
Jan
Jan 2017년 8월 3일
편집: Jan 2017년 8월 3일
I do not think that a clear all magically influences the file permissions, which are controlled by the operating system. Even the WordPad "trick" does not seem to get the real source of the problem. Changing the current folder to a location you have write permissions to should solve the problem with out magic and tricks.

댓글을 달려면 로그인하십시오.


Nikhil Kedia
Nikhil Kedia 2017년 8월 3일
I faced this issue too. May be you can try Save Copy as option in the script toolbar's Save dropdown. This is likely because of permission issues. May be some Windows Firewall Setting. Try changing settings If the above does not work, save it in a wordpad as .m file.
Or, just use octave.
  댓글 수: 2
Image Analyst
Image Analyst 2017년 8월 3일
편집: Image Analyst 2017년 8월 3일
Saving a copy won't work. And it's not a firewall issue. And saving from Wordpad vs. from MATLAB, or saving from Octave, also won't work.
Like I said, the whole problem is he was trying to save the file under c:\Program Files. And Windows does not allow that.
Jan
Jan 2017년 8월 3일
I agree with Image Analyst. The problem is clear: You can create or modify files only, if you have write permissions to the folder.

댓글을 달려면 로그인하십시오.


vincent caillet
vincent caillet 2018년 10월 8일
Hey guys,
This error occured for me when I saved the .mat file multiple times a second to OneDrive. OneDrive automatically saves the files to its own cloud, and I guess it was running into some issues. I closed OneDrive to avoid automatic updates and it now works very well.
So my advice is to avoid working on Onedrive, Google Drive or some server if your code is designed to save the .mat files often into a server that updates itself quite often.
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 10월 8일
In at least one MATLAB release there was a problem working with OneDrive when automatic download was turned on.

댓글을 달려면 로그인하십시오.


Ben Hawkins
Ben Hawkins 2019년 3월 14일
편집: Ben Hawkins 2019년 3월 14일
I recently encountered the same issue. This is NOT a problem with the save destination (at least for me). It is a bug related to OneDrive. Turning OneDrive off is NOT an acceptable solution.
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 3월 15일
The problem was not OneDrive on or off: it was the automatic synchronization of OneDrive. You can leave OneDrive on if you are willing to manually synch.
Ben Hawkins
Ben Hawkins 2019년 3월 15일
My institution all but requires the use of OneDrive. Manual syncing is a poor solution. Restarting MATLAB worked for me, so its not a big issue, but I still feel this is a bug to be tackled by Mathworks.

댓글을 달려면 로그인하십시오.


Mate Misho
Mate Misho 2019년 4월 19일
I had a similar problem and solved it. Whoever reads this should check his folderpath if any folder name has a space. I changed it to '_' and saving worked just fine.

Alexandre Delaux
Alexandre Delaux 2019년 8월 2일
I had the same problem saving a function in the folder I've been working in for days. (It happened in the middle of a working session, it was not the first thing I did upon start of Matlab).
I did the >>pwd command and Matlab was indeed pointing at the right folder...
I'm on a Ubuntu 16.04 OS, Matlab R2017a
Relaunching Matlab restored the saving capability but this is odd and annoying

Michael Cervoni
Michael Cervoni 2021년 9월 15일
I just ran into this issue with 2021a. I was saving a file automatically and had included the current date and time in the file name. The datetime string had the char ":" in it which is not a vaild charactor in a windows file name. Removing this corrected the issue.

Ruby Barron
Ruby Barron 2021년 9월 16일
Can someone help? We can’t figure out why simulink or any matlab files won’t open. Tried redirecting the path to a simpler location and let matlab have full access, so no restrictions.
  댓글 수: 1
Image Analyst
Image Analyst 2021년 9월 16일
Yes, tech support can. We can't because you have supplied virtually no information. Plus, we cannot set up a screen sharing session with you like tech support can.

댓글을 달려면 로그인하십시오.


Dimitrios Konstantinidis
Dimitrios Konstantinidis 2023년 4월 19일
Windows Security seems to think that Matlab is ransomware. Go to Windows Security and under "Ransomware protection" click "manage ransomware protection" and disable "controlled folder access". This worked for me, altough clearly not an ideal solution.
  댓글 수: 1
Andreas Schnell
Andreas Schnell 2023년 11월 20일
Thank's a lot. That's also my issue.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by