setdiff output differs from matlab

soren at hauberg.org soren at hauberg.org
Thu Sep 18 05:48:29 CDT 2008


Quoting Sergei Steshenko <sergstesh at yahoo.com>:
> [snip]
>> So if the args are both vectors, but different orientations
>> then Matlab
>> converts them both to be row vectors.
>>
>> D.
>
>
> In the light of David's conclusion could anyone please check how
> Matlab copes with the case described here:
>
> http://www.nabble.com/inconsistent-row-<->-column-sub-vector-behavior-td19109349.html
>
> ?
>
> John said Matlab would fail too, but since it can correctly guess
> how to deal with row <-> column vector in this case, maybe it is smart to
> guess correctly also in the case I reported.
>
> John's exact words:
>
> "
> It fails because the column vector and the row vector do not have
> compatible dimensions.
> ",
>
> however, the Email does not contain a copy-pasted Matlab session to
> confirm the statement.

>> vector_length = 4

vector_length =

      4

>> column_vector = zeros(vector_length, 1)

column_vector =

      0
      0
      0
      0

>> row_vector = ones(1, vector_length)

row_vector =

      1     1     1     1

>> column_vector(2:vector_length) = row_vector(2:vector_length)

column_vector =

      0
      1
      1
      1

>> column_vector(2:vector_length) += row_vector(2:vector_length)
??? column_vector(2:vector_length) += row_vector(2:vector_length)
                                     |
Error: The expression to the left of the equals sign is not a valid target for
an assignment.

So, Matlab behaves like Octave.

Søren




More information about the Bug-octave mailing list