Does MATLAB2019B automatically add semicolons in m files?
9 views (last 30 days)
Show older comments
I just updated to 2019B from 2015. I have noticed that when I open my m files, there are semicolons added where I certainly did not have them before. I've noticed it at the end of certain if statements and for statements. e.g. if aa is a vector, then
for a = aa
...
end
will be replaced with
for a = aa;
...
end
Does 2019B have the ability to edit your code without telling you? I'm not just talking auto-indenting as you type or anything like that. It actually seems to be editing the text of a file upon opening it such that the code is different than how you saved it. This is a bit disturbing...
It doesn't happen at all if/for statements. Weirdly, the Editor gives warnings about unnecessary semicolons in the cases where they have been added, so the auto-replacement doesn't seem to know what Editor knows.
1 Comment
Rik
on 17 Dec 2019
Are you sure it is the new Matlab release that is doing the editing? Were you able to find a work flow that reproduces this? It sounds like a serious bug to me if it is indeed Matlab that edits your code like this.
Answers (4)
John D'Errico
on 18 Dec 2019
Edited: John D'Errico
on 18 Dec 2019
R2019b here.
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.7.0.1216025 (R2019b) Update 1
As a test, I created this m-file. See the lack of a semi-colon. I then saved it.
function test(A)
A = rand(3)
end
Close the file. Then edit it, opening the file. Here it is:
function test(A)
A = rand(3)
end
No semi-colon added. MATLAB changed nothing.
0 Comments
Steven Lord
on 20 Dec 2019
I'm not aware of anything in MATLAB itself that I would expect to do this.
Do you have any add-ons installed? On the Home tab of the Toolstrip, click on the triangle below "Add-Ons" in the Environment section and select "Manage Add-Ons". What if anything does the Add-On Manager list other than MathWorks toolboxes?
Are you storing your files in a source control system? If so, which one?
How are you opening the files? Are you using the Open icon in the File section of the Home tab on the Toolstrip, are you using the edit function (and are you using the edit function included in MATLAB in that case), are you using some other function (one you've downloaded, were given, or wrote), etc.? If the latter, does that other function try to "beautify" your code (and eliminate Code Analyzer warnings) by adding the semicolons?
0 Comments
See Also
Categories
Find more on Matrix Indexing 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!