Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Making a square matrix from two vector
Replies: 22   Last Post: Mar 19, 2013 12:37 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 9,333
Registered: 6/7/07
Re: Making a square matrix from two vector
Posted: Feb 12, 2013 5:29 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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:10-2i
> 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 special-cased to ignore the imaginary parts (replacing them w/
0). IOW, it appears the parser turns the expression '1i:10-2i' into '0:10'


>> 2i:10-2i
Warning: Colon operands must be real scalars.
ans =
0 1 2 3 4 5 6 7 8 9 10
>> 2i:4-2i
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

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.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2016. All Rights Reserved.