MATLAB: Warning about a value indexed with no subscripts and error in future release

error-in-future-releaseMATLABsimulinkvalue-indexed-with-no-subscripts

Why do I receive a warning that says a value was indexed with no subscripts, and this will be an error in a future release?

Best Answer

The source of a warning with the structure
Warning: A value of class "<some class>" was indexed with no subscripts specified. Currently the result of this operation is the indexed value itself, but in a future release, it will be an error.
is code which uses indexing into variables with empty parentheses. When all warnings are enabled, indexing into variables with empty parentheses issues a warning message of this type. For example,
>> warning('on');
>> x = [1 2 3 4 5];
>> y = x()
Warning: A value of class "double" was indexed with no subscripts specified. Currently the result of this operation is the indexed value itself, but in a future release, it will be an error.
y =
1 2 3 4 5
As of R2018b this syntax may still be invoked by some shipped functions (e.g. linmod), however it is set to be eliminated in the future. Note that
  • This warning message is suppressed (i.e. 'off') by default.
  • The command warning('on') turns on all warnings, including those which are 'off' by default.
  • This warning may not have been issued in some older releases.
To see a list of warnings suppressed by default, enter warning without arguments to the Command Window after restarting MATLAB. If you would like to enable all warnings with the exception of this one, you can use the commands
>> warning('on');
>> warning('off','MATLAB:subscripting:noSubscriptsSpecified');