In MATLAB you can create an array of integers easily with
N = 100; % Number of points
A = 1:N; % row vector of 1,2,3,..., 100
If I want a column vector instead of a row vector, I can do that with
A = [1:N].';
Now, MATLAB warns me that
Use of brackets [] is unnecessary. Use parentheses to group if necessary.
Well, they are not unnecessary, because 1:N.'
creates a row vector, as only the scalar N
is transposed, as opposed to the full array.
I can of course suppress this message on that line, in that file, or in all files, but why does MATLAB throw this warning in the first place, as it seems that I can't do without those brackets in this case?
It turns out a large part of the confusion stems from the usage of American English by The MathWorks, as the rest of the English-speaking world uses the term brackets for ()
and the term square brackets for []
. See Wikipedia