csvwrite/dlmwrite Cannot Open File

조회 수: 17 (최근 30일)
FATLAB
FATLAB 2015년 1월 30일
Hello everyone,
I'm trying to write a matrix to a CSV file but I keep getting an error saying the file cannot be opened. There are a lot of other posts bout this error but I still can't seem to get it working. Below is the code I've typed into the command window.
>> R = [1,2,3;4,5,6;7,8,9];
>> csvwrite('txt.csv', R)
Error using dlmwrite (line 130)
Could not open file txt.csv
Error in csvwrite (line 43)
dlmwrite(filename, m, ',', r, c);
>>
I can't understand why this error keeps occurring. Any help would be appreciated!
  댓글 수: 2
Hikaru
Hikaru 2015년 1월 30일
편집: Hikaru 2015년 1월 30일
I cannot reproduce your error.
Error using dlmwrite (line 130)
^ Why did MATLAB tell you that you have error in dlmwrite when you're calling csvwrite? Did you copy everything and post them here? Try clearing your workspace and see if
>> R = [1,2,3;4,5,6;7,8,9];
>> csvwrite('txt.csv', R)
if it produce the same error?
And maybe you should check that you are in the correct MATLAB path. If you don't have permission to write in that folder, maybe that's the source of your problem.
Gokul Manappetty Syamalan
Gokul Manappetty Syamalan 2021년 3월 3일
I also had same issue and fixed by correcting the path.
Please click on the saved file and right click and add to path. It will work. !!

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

답변 (3개)

Ninjan
Ninjan 2015년 3월 12일
I got the exact same error as Hikaru. Can not figure out why. I have the permission to write, it is also in the folder as other files from MATLAB is created. The path is included in MATLAB.
Regards, Ninjan
  댓글 수: 1
Gokul Manappetty Syamalan
Gokul Manappetty Syamalan 2021년 3월 3일
Its path error sir, Please click on saved file or add current path and try again it will work.

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


Arthur Ryzak
Arthur Ryzak 2019년 4월 6일
I got that same error for my data and for the code Hikaru posted. Turned out my current folder was root. Type pwd and make sure your current folder is the one you think it is.

Yohanna Rodriguez
Yohanna Rodriguez 2019년 4월 26일
Well, I had the same problem but I fixed it as soon as I changed the folder to the one I normally use for my Matlab files

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by