Copilot cannot access matlab environment?

In most IDEs you can ask the LLM about the code on the screen, and the copilot chat seems to think it can access the editor, although I could not get it to actually do so. After trying to do this and getting a lot of conflicted answers I finally got this:
Me
Can you read files that are currently open in matlab?
Copilot
No — I cannot directly read files on your machine or access the MATLAB Editor. I can only work with text or files you share here.
Is that correct? The chat is not actually integrated with the Matlab like in a normal IDE (VS, VSCode, etc)? Is there some way to fix this or otherwise get it to work with the environment? Or if it is intentional it might be helpful to explain that the system is much more limited than it thinks it is.

Answers (1)

Cris LaPierre
Cris LaPierre 33 minutes ago
Edited: Cris LaPierre 31 minutes ago
If you are using R2025b or earlier, yes, MATLAB Copilot does not automatically have access to the editor. You must manually copy/paste code into your chat to include it in the chat context.
However, in R2026a and MATLAB Online, MATLAB Copilot does have file context awareness (release notes). You may have to install an update for this feature to be enabled (check the bell icon in the upper right of your desktop MATLAB).
This feature enables Copilot Chat to automatically track the file currently in focus and also allows you to explicitly attach additional files to enrich the conversation context. Copilot Actions like Explain Code, Generate Comments etc. are now capable to act on the entire file and no longer enforce a selection in the code.
  • Additional context can be included using the Add File button. Currently support is limited to M and MLX files.
  • Context can be removed by clicking the × on the context pill.
You'll see the context just above the prompt field. Here, you can see I have a file named FourierCoeffs open in my editor.
If you click on the paper clip, you can add additional files to the context.
There are a couple other ways to use MATLAB Copilot that may also be helpful.
  • It is possible to create a non-interactive prompt inside your script using ctrl+shit+P.
  • If you highlight code in your script, you can use the Copilot item in the Live Editor tab's toolstrip to have Coplilot explain or comment your code, among other things.
For a more thorough introduction to MATLAB Copilot, consider going through the Introduction to MATLAB Copilot course on Coursera.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Tags

Asked:

on 14 May 2026 at 15:08

Edited:

about 14 hours ago

Community Treasure Hunt

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

Start Hunting!