MATLAB: Keyboard shortcut for semicolon

keyboard shorcut for semicolon

Hi…
Is there any keyboard-shortcut to write semicolon (;) at the last of selected lines?
Like (CTR+R) for putting (%) at the beginning of lines.
Thanks

Best Answer

Your concept of how to use MATLAB is making your own life more difficult.
Instead of copying the data into Mfiles and trying to execute this, you should simply keep your data where it is and read the data itself into MATLAB using one of its many functions designed exactly for that purpose: csvread, dlmread, textscan, or any or of the other data reading functions that you will find in the MATLAB documentation on file reading and writing .
The reason there is no shortcut is because trying to build large executable data files is poor programming practice, and no programmer writes large executable files of their data: this is generally considered to be a buggy and inefficient process, and as has already been commented on in this page by per isakson and John D'Errico.
In MATLAB, like most programming languages, data and the executable code are considered to be two different paradigms and are not usually stored together or handled in the same way. This helps make code more robust, by allowing us to create code that is generalized to a reasonable degree and not specific to one set of data. It also allow us to change the data without having to change the code itself. Keeping them separate encourages writing re-usable and generalized code, rather than writing code for one specific set of data.
It would be more usual to store simple numeric data in something like a .CSV file, some kind of binary file or a .MAT file, and import this into MATLAB using the usual file-reading functions.
For example you might have some numeric and image data from an experiment: these would normally be kept in the simplest storage form possible, and only read into MATLAB when required. You can see that making the numeric data a callable script or function is rather unbalanced, as the image data would likely not get treated like this.
This topic has been discussed before on MATLAB Answers: