Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 Messages: [ Previous | Next ]
 dpb Posts: 9,850 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:10-2i
>
> Discussed previously in

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'

Examples--

>> 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
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.

--

Date Subject Author
2/8/13 Jerry
2/8/13 Barry Shaw
2/8/13 dpb
2/8/13 james bejon
2/9/13 Bruno Luong
2/9/13 james bejon
2/9/13 Bruno Luong
2/12/13 james bejon
2/12/13 Steven Lord
2/12/13 Bruno Luong
2/12/13 dpb
2/12/13 Bruno Luong
2/12/13 dpb
2/13/13 Bruno Luong
2/13/13 dpb
2/14/13 Bruno Luong
2/14/13 dpb
2/14/13 Bruno Luong
2/14/13 dpb
2/14/13 dpb
2/13/13 james bejon
3/18/13 James
3/19/13 Bruno Luong