Writing to text file problem

Hello everybody,
I need to import some basic data in a very basic form to Matlab. I am able to import the data with 'load' and 'dlmread' commands, but when using 'save' and 'dlmwrite' commands , i am getting errors.
-I have created the files manually, files to read from and to write to are different files.
-Matlab can open and read both of the files but cannot write to any of the files.
-Text files are located at the matlab folder which is under the 'Documents'
-I don't know if matlab has permission to access/change the files/folders but i think i wouldn't be able to make matlab read the files if it didn't have the access permission.
dosya = dlmread('delimite.txt' , ',' ) ;
c1 = dosya(:,1) ;
c2 = dosya(:,2) ;
dlmwrite('delimite2.txt' ,[c1 c2], ',' )
Error using dlmwrite (line 124)
Cannot open file delimite2.txt.
Error in Write_deneme (line 6)
dlmwrite('delimite2.txt' ,[c1 c2], ',' )
Data inside the text file is as follows;
12, 24
13, 46
34, 98
28, 52
I am using matlab R2015a and windows 10-64 bit. Problem is the same on my laptop and desktop. Both have the same windows and Matlab versions. But i have my friends who can run the code and write to text files without any problem.
Is there any easy solution to this problem, or alternatives that i can try? Sorry if there is any missing information.

Réponses (1)

Pekkucuk
Pekkucuk le 26 Mar 2018

0 votes

Alright, i have solved this.
On the preferences window, general tab, i have changed the initial working folder directory from "C:/ProgramFiles/Matlab/MatlabProductionServer/R2015a/bin" to "ThisPC/Documents/Matlab" and it solved the issue. Only thing that remains now is the form of writing.
I have opened this file with the code;
12, 24
13, 46
34, 98
28, 52
61, 85
And with dlmwrite it gave me the output in this form:
24,12 46,13 98,34 52,28 85,61
If you can help me correct it to the row and column form, i would be grateful.

Catégories

En savoir plus sur Data Import and Export dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by