MATLAB 5.3 (R11) v. Octave 3.0.0 script compatibility error?
John W. Eaton
jwe at octave.org
Thu Apr 23 14:04:03 CDT 2009
On 23-Apr-2009, v4r4n wrote:
| After finally getting some MATLAB scripts from an old thesis to work with a
| MATLAB (R11) on WinXP, I decided to try and see if the same scripts worked
| with Octave.
|
| Using Ubuntu 8.04 and Octave 3.0.0 these commands:
|
| VEC = [1, 2, 3];
| for i=VEC
| DB(i==VEC)=-15;
| end
|
| produce these error messages:
|
| error: invalid index = 0
| error: assignment failed, or no method for `scalar = scalar'
| error: evaluating assignment expression near line 3, column 15
| error: evaluating for command near line 2, column 1
|
| Please forgive me if this is a known bug/error. Since I'm new to both
| MATLAB and Octave, I'm unsure how to search for and describe what is going
| on here.
|
| If this is the wrong place to post and ask such questions, please point me
| in the right direction.
Octave 3.1.x does this:
octave3.1:1> VEC = [1, 2, 3];
octave3.1:2> for i=VEC
> DB(i==VEC)=-15;
> end
octave3.1:3> DB
DB =
-15 -15 -15
The loop
for i = VEC
assigns each column of VEC to i in turn. The first time the loop body
is executed, i is set to 1, and i == VEC produces the logical value
[1, 0, 0], so you assign the first element of DB to -15. The second
time through the loop, i is set to 2 and i == VEC produces the logical
value [0, 1, 0], so you assign the second element of DB to -15. And
so on.
Is that what expect?
So yes, there was a compatibilty problem in the older version of
Octave, but I think that hsa been fixed for the next release.
The problem also should be fixed in the current 3.0.x release (3.0.5).
jwe
More information about the Bug-octave
mailing list