[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
manipulation of matrix elements
From: |
John W. Eaton |
Subject: |
manipulation of matrix elements |
Date: |
Thu, 16 Dec 1999 10:24:52 -0600 (CST) |
On 16-Dec-1999, Michael Roth <address@hidden> wrote:
| I tried to set a lower limit for matrix elements using the find command.
| I think there is a bug. Have a look at the following lines:
|
| s=rand(2)
| s =
| 0.47926 0.89733
| 0.77293 0.02806
|
| >> [i,j]=find(s<=0.5)
| i =
| 1
| 2
|
| j =
| 1
| 2
|
|
| >> s(i,j)=0.5 | In Matlab, this command gives
| s = | s =
| 0.50000 0.50000 | 0.50000 0.89733
| 0.50000 0.50000 | 0.77293 0.50000
What version of Matlab does this?
If Matlab *does* behave this way, I think it is a bug in Matlab, not
Octave, because it leads to an ambiguity depending on the sizes of the
index vectors.
I think what you want to write is
i = find (x <= 0.5);
s(i) = 0.5;
which should work in a compatible way if do_fortran_indexing is set to
a non-zero value.
jwe
-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.che.wisc.edu/octave/octave.html
How to fund new projects: http://www.che.wisc.edu/octave/funding.html
Subscription information: http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------