improvements in matlab compatibility

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

improvements in matlab compatibility

Anders Holtsberg


During the 4 hour work on converting the statistics stuff
today I have collected the most urgent questions/suggestions
for matlab compatibility.

=== 1 ===

        The notation  y = x(:)  does not work. This is
        very much cleaner than  y = reshape(x,prod(size(x)),1).
        And  A(find(A>0))  should give me a column vector.
        Please copy the matlab conventions since they are
        very effective. Also x(:,ones(m,1)) for a column vector
    x  is very useful.

=== 2 ===

        y(:) = x  does not work either. y = reshape(x,size(y,1),size(y,2))
        is not more readable or writable. And while we're at it:
        y(find(y<0)) = 0  with scalar right hand side will work
        in matlab 5.0 says mathworks, this is a good thing too.

=== 3 ===

        Skip the "warning: empty matrix found in matrix list"-
        error message. I know what I'm doing.

=== 4 ===

        Skip the read-only property of I and J. I want to
        use them as I want too. Besides I already have written
        matlab-programs with lots of I and J.

=== 5 ===
 
        The old style  rand  crashes many programs. rand([3 4])
        means a 3 x 4 - matrix im matlab 4.x, not a 1 x 2 one.
        This will be changed in octave I think somebody said?

Best wishes

Andy

======= Anders Holtsberg ====================== http://www.maths.lth.se ===
  . .:  Department of Mathematical Statistics   phone  +46 46 104276    ..
.: :.   Box 118, Lund Institute of Technology   fax    +46 46 104623   :.
======= S-221 00 Lund, Sweden ================= [hidden email] ======

Reply | Threaded
Open this post in threaded view
|

improvements in matlab compatibility

John W. Eaton-6
Anders Holtsberg <[hidden email]> wrote:

:         The notation  y = x(:)  does not work.

It will work as you expect if you set the variable

  do_fortran_indexing = "true"

See the section on compatibility with Matlab in the FAQ.  The FAQ
should be included in the source and binary distributions.

: Also x(:,ones(m,1)) for a column vector x is very useful.

This seems to work for me in version 1.1.1.

If you find a bug, please submit a complete bug report to
[hidden email].  Please read the Bugs chapter in the
manual to see how to write a bug report so that the bug can be fixed.

:         y(:) = x  does not work either.

I'm not sure what the problem is here.  What size are y and x?  This
should work in 1.1.1 with do_fortran_indexing = "true" if y and x have
the same number of elements.

: And while we're at it: y(find(y<0)) = 0  with scalar right hand side
: will work in matlab 5.0 says mathworks, this is a good thing too.

This is probably a reasonable change to make.  I've added to the list
of things to do in the PROJECTS file.

:         Skip the "warning: empty matrix found in matrix list"-
:         error message. I know what I'm doing.

You can turn this warning off by setting the variable

  empty_list_elements_ok = "true"

In some future version, I intend to make it possible to disable or
enable all warnings on an individual basis.

:         Skip the read-only property of I and J.

This is planned for 1.2.

:         The old style  rand  crashes many programs. rand([3 4])
:         means a 3 x 4 - matrix im matlab 4.x, not a 1 x 2 one.
:         This will be changed in octave I think somebody said?

This has already been done for 1.2.

Thanks,

jwe

Reply | Threaded
Open this post in threaded view
|

Re: improvements in matlab compatibility

niles-3

>Anders Holtsberg <[hidden email]> wrote:
>
>:         The notation  y = x(:)  does not work.
>
>It will work as you expect if you set the variable
>
>  do_fortran_indexing = "true"

etc...

As these are everyone first problems with Octave, perhaps these Matlab
compatability options should be the default.

        What do you think?
        Rick Niles.


Reply | Threaded
Open this post in threaded view
|

Re: improvements in matlab compatibility

Martin Maechler
Yes, I had the same thought about

        do_fortran_indexing : the default should really be  'true' !

>>>>> "niles" == niles  <[hidden email]> writes:

    >> Anders Holtsberg <[hidden email]> wrote:
    >>
    >> : The notation y = x(:) does not work.
    >>
    >> It will work as you expect if you set the variable
    >>
    >> do_fortran_indexing = "true"

    niles> As these are everyone first problems with Octave, perhaps these
    niles> Matlab compatability options should be the default.