Is there a MATLAB add-in to Visual Studio?
I found an old one that works with Visual Studio 6. There's also the Eclipse plugin, but I prefer Visual Studio as an IDE.
The MATLAB® Coder™ Interface for Visual Studio® Code™ Debugging support package allows you to use Visual Studio Code to view and debug C and C++ code. For example, code that you generate from MATLAB code and Simulink® models or code that you import from external libraries.
Open the command palette (under "View" or with shortcut ctr+shift+p) and find the "Run Matlab File" command.
Command Syntax and Function SyntaxIn function syntax, inputs can be data, variables, and even MATLAB expressions. If an input is data, such as the numeric value 2 or the string array ["a" "b" "c"] , MATLAB passes it to the function as-is. If an input is a variable MATLAB will pass the value assigned to it.
On the Editor or Live Editor tab, in the Section section, select Run and Advance. Run the code in the selected section, and then run all the code after the selected section. On the Editor or Live Editor tab, in the Section section, select Run to End. Run to a specific line of code and pause.
However familiar you are with VS, I would recommend abandoning it when you use Matlab. I've used multiple IDEs while developing code for Matlab, and I always come back to the built-in editor.
Matlab's editor is easy to use, and fully integrated with the program. Since Matlab is a scripting language, the debugger is also very flexible and interactive.
There are many useful features of the editor that would be (most likely) impossible in VS, including:
An example: You are debugging a function, and you come to a tricky line of code to debug. Instead of stepping over that line, you can highlight it and evaluate it in the command window, or even some small portion of the line. In this way, you can fix your code iteratively without ever leaving the debugger.
The only time I would recommend using VS for Matlab, is when writing/debugging MEX functions. You won't use VS to compile them, but VS is definitely a better IDE for writing C/C++ code.
When developing software, always use the IDE that is best suited for what you are doing. Learning a new IDE can be daunting, but Matlab's editor has a relatively low learning curve compared to others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With