MATLAB: I am unable to create a text file on matlab 2013a.The value in variable ‘errmsg’ is ‘Permission denied’.Usage of other permissions like w+,a,A,W also gives the same result.The only permissions working are ‘r’ and ‘r+’. How to solve this problem

File Operationsfopenpermissions

Here's the code:
x = 0:.1:1;
A = [x; exp(x)];
[fileID,errmsg] = fopen('exp.dat','w');
fprintf(fileID,'%6s %12s\n','x','exp(x)');
fprintf(fileID,'%6.2f %12.8f\n',A);
fclose(fileID);

Best Answer

You need to be given write access to the current directory if you intend to write a file to that directory. This is not a MATLAB problem, but a permissions issue for your computer.