MATLAB: How to debug the MATLAB code called from Excel using Spreadsheet Link

debugexexcellinkspreadsheetSpreadsheet Link

I have written a function in MATLAB which I am calling from Excel using Spreadsheet Link. I want to be able to debug my MATLAB code when I run the VBA code.

Best Answer

Before you begin, I recommend closing all open MATLAB sessions. Spreadsheet Link will start an instance of MATLAB to use. Closing other MATLAB windows will make it easier for you to locate the MATLAB instance started by Excel.
  1. Open Excel
  2. Verify that you have the correct preferences set to be able to debug:
  3. Select "Preferences" from the MATLAB menu in the "Home" tab of the ribbon.
  4. Check "Use MATLAB desktop".
  5. Click "OK"
  6. Start MATLAB from Excel
  7. Select "Start MATLAB" from the MATLAB menu in the "Home" tab of the ribbon.
  8. You should see MATLAB start.
  9. In MATLAB, navigate to the folder where the function you want to debug is present.
  10. Put a break point in that function.
  11. In Excel, run the VBA code which calls the MATLAB function.