[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Differences between Octave and Matlab on division (/) operator with
From: |
Juan Pablo Carbajal |
Subject: |
Re: Differences between Octave and Matlab on division (/) operator with scalar and vector |
Date: |
Sat, 25 Mar 2017 19:51:50 +0100 |
On Sat, Mar 25, 2017 at 6:48 PM, José Luis García Pallero
<address@hidden> wrote:
> Hello:
>
> Using this variables:
>
> a = 2;
> b = [1 2 3];
>
> For the operation a/b or 2/b or b/2 I obtain an error in Octave and
> Matlab due to wrong dimensions. But if I declare b as a vector column
> as b=[1 2 3]' I obtain in Octave:
>
>>> a/b
> ans =
>
> 0.14286 0.28571 0.42857
>
> and in Matlab:
>
>>> a/b
>
> ans =
>
> 0 0 0.6667
>
> What is the reason of this difference? Why the operation is legal with
> b as column vector and illegal with row vector?
>
> Thanks
>
> --
> *****************************************
> José Luis García Pallero
> address@hidden
> (o<
> / / \
> V_/_
> Use Debian GNU/Linux and enjoy!
> *****************************************
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave
In Octave a/b when b is a matrix (any size), is equivalent to
a*inv(b), in this case a*pinv(b) (try it out).
I can't see what matlab is doing, but the last element is 2/3.
I also do not understand why there is an error in the first case,
should given the same result...i.e. apply a*pinv(b) when b is a row
vector