Results 1 to 4 of 4

Math Help - MATLAB: Vectorized arithmetic operations

  1. #1
    Junior Member
    Joined
    Oct 2008
    Posts
    49

    MATLAB: Vectorized arithmetic operations

    Hi

    .* is an array operator (element-by-element operator). Now, if a=2 and x=[1 2], then why am I allowed to calculate a.*x? I mean, it is an element-by-element operator, so it should give me an error.

    Furthermore, * is a matrix-operator (according to Support - Code Vectorization Guide). If that is the case, then why am I allowed to calculate the product x*a? Only a*x should be allowed.

    I hope you will help me by shedding some light on this.

    Best,
    Niles.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    I believe that answer to this is that MATLAB treats single element arrays as a "scalar" value therefore .* and * are equivalent if either one of the components is scalar.

    Regards Elbarto
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Oct 2008
    Posts
    49
    Quote Originally Posted by elbarto View Post
    I believe that answer to this is that MATLAB treats single element arrays as a "scalar" value therefore .* and * are equivalent if either one of the components is scalar.

    Regards Elbarto
    Thanks. Does that mean that MATLAB itself transposes the vector a in the case x*a?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Niles_M View Post
    Thanks. Does that mean that MATLAB itself transposes the vector a in the case x*a?
    No a is a scalar and for it makes no difference if you have a*x or x*a

    if a=[1,2] x=[2,3] a and b are non-compliant matrices and neither a*x or x*a will execute without throwing an error (but a.*x and x.*a will execute properly).

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Number of arithmetic operations
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: May 13th 2010, 01:10 PM
  2. Matrix Operations in MATLAB
    Posted in the Math Software Forum
    Replies: 0
    Last Post: February 9th 2010, 08:31 PM
  3. Arithmetic with * Operations
    Posted in the Algebra Forum
    Replies: 1
    Last Post: November 23rd 2009, 09:17 AM
  4. arithmetic operations in different number system
    Posted in the Discrete Math Forum
    Replies: 0
    Last Post: February 27th 2009, 02:38 AM
  5. how to do arithmetic operations in galois field
    Posted in the Advanced Algebra Forum
    Replies: 1
    Last Post: December 1st 2008, 05:09 AM

Search Tags


/mathhelpforum @mathhelpforum