Is "ix = 1:[4:12]" legal?

Is this behavior documented (for R2013a)
>> ix = 1:[4:12]
ix =
1 2 3 4
The Code Analalyzer issues a warning but Matlab evaluates the code without warning or error. I think a warning is appropriate.
&nbsp

 Accepted Answer

Sean de Wolski
Sean de Wolski on 30 Dec 2014
Edited: Sean de Wolski on 30 Dec 2014
Documented:
web(fullfile(docroot, 'matlab/ref/colon.html'))
If you specify nonscalar arrays, MATLAB interprets j:i:k as j(1):i(1):k(1)

1 Comment

... but it will let coding mistakes pass unnoticed.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!