Clear Filters
Clear Filters

Compiling with function with MATLAB coder leads to filesystem error

31 views (last 30 days)
I am running into an issue where when I use the MATLAB Coder to compile a function in MEX, once the file is created and the Coder is attempting to verify the function, it returns an error. When I run my code calling the MEX function, I get the following error message:
Additionally, if I try to delete the file in the Current Folder window, it just stays there and doesn't get deleted. I would appreciate any insight as to solutions for this.
Not Sure what additional information might be useful But I'll be sure to append it below as things get requested.
Paul Imler
Paul Imler on 14 Apr 2022
I have tried to see what is blocking the file to no avail. I attempted to research the link and follow the instructions, but I was unable to delete any of the files or free them from another process (I was unable to see if another process was blocking them). I guess the issue now is why is MATLAB generating a file that can't be accessed?

Sign in to comment.

Answers (1)

arushi on 29 Dec 2023
Hi Paul,
I understand that you are facing the error while using the MATLAB Coder to compile a function in MEX.The error message fl:filesystem:AccessDenied suggests that MATLAB is encountering a permissions issue when trying to access or modify a file on the file system. This could be due to various reasons, such as the file being in use by another process, insufficient user permissions, or the file being marked as read-only.
Here are some steps you can take to troubleshoot and resolve the issue:
  1. Check File Permissions: Ensure that you have the necessary permissions to read, write, and execute the file. You can check the file properties and modify the permissions if needed.
  2. Close Other Programs: Make sure that no other applications or instances of MATLAB are using the file. Sometimes, a file may be locked because it is open in another program.
  3. Use Administrator Privileges: Try running MATLAB as an administrator (if you are on Windows) to ensure it has the permissions needed to access the file.
  4. Check for Read-Only Attribute: Verify that the file is not set to read-only. You can change this by right-clicking on the file, selecting Properties, and unchecking the Read-only option.
  5. Use Command Line to Delete: If you are unable to delete the file from within MATLAB, you can try using the command line. On Windows, you can use the Command Prompt with administrator privileges, and on macOS/Linux, you can use the Terminal.
  6. Check for Antivirus Interference: Sometimes antivirus software can interfere with file operations. Temporarily disable your antivirus and try again.
  7. Check MATLAB Path: Ensure that the MATLAB path is set correctly and that it does not include any folders for which you do not have proper access permissions.
When trying to resolve file access issues, proceed with caution, especially when using commands that can permanently delete files or alter permissions.
Hope this helps.
Thank you


Find more on MATLAB Coder in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!