MATLAB: Each time i run the simulation i get the error attached below. Please help

light projectMATLAB and Simulink Student SuiteMATLAB Compiler

Please see the attached image.

Best Answer

Are you using cd, change directory, anywhere in your code to go to that Program File folder? What is your current working directory, when you type cd ?
Change your current working directory to one where you have permission to create files.
WorkDir = 'c:\Users\user_name\Desktop\MyFolder'; %Your working directory
if ~exist(WorkDir, 'dir')
mkdir(WorkDir) %Make sure you do have a directory
end
cd(WorkDir)
run your code now
The better solution is to find the code where you are trying to write files, and make sure to use the FULL FILE PATH, and not relative file path.
For instance,
plot(1:10, 1:10)
[FileName, FilePath] = uiputfile('*.png');
saveas(gcf, FileName) %will save to current working dir
saveas(gcf, fullfile(FilePath, FileName)) %will save to an exact location