dpb
Posts:
9,595
Registered:
6/7/07


Re: Making a square matrix from two vector
Posted:
Feb 12, 2013 5:29 PM


On 2/12/2013 3:35 PM, Bruno Luong wrote: > It's not possible to explain better than Steve. > > Just one thing: > >> "If you specify nonscalar arrays, MATLAB interprets j:i:k as >> j(1):i(1):k(1)." >> > > This is still incomplete to explain the result of: > > a = 1i:102i > > Discussed previously in > http://www.mathworks.com/matlabcentral/newsreader/view_thread/261665
Don't know what the thread concluded (if anything) but empirically it appears specialcased to ignore the imaginary parts (replacing them w/ 0). IOW, it appears the parser turns the expression '1i:102i' into '0:10'
Examples
>> 2i:102i Warning: Colon operands must be real scalars. ans = 0 1 2 3 4 5 6 7 8 9 10 >> 2i:42i Warning: Colon operands must be real scalars. ans = 0 1 2 3 4 >> 2i:4 Warning: Colon operands must be real scalars. ans = 0 1 2 3 4 >>
Seems as reasonable a choice as any if it isn't going to just error entirely (which would probably be my first reaction of "proper" behavior). Guess one could always have done abs() on the complex values but seems like too much of a performance hit on the normal case might result...
Why would anyone write such, anyway, and expect anything meaningful? I'd relegate it to the bin of bad syntax and abort if it were my choice.


