[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## newbie question: assigment to N-d arrays returns strange values

**From**: |
Amir Seginer |

**Subject**: |
newbie question: assigment to N-d arrays returns strange values |

**Date**: |
Sat, 06 Aug 2005 09:31:15 +0300 |

**User-agent**: |
Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720) |

Hello,

`This might be a known problem, but I couldn't find any reference to it.
``When assigning to an n-dimensional array (see below) I get results which
``are different from Matlab. Also, in one case I get some strange values
``in the array as well.
`
I wrote the the following code in Octave (using --traditional):
>> m=zeros(3, 2, 2) ;
>> a= [1 2 3 4] ;
>> m(3, :) = a
m =
ans(:,:,1) =
0 0
0 0
1 2
ans(:,:,2) =
0 0
0 0
0 0

`which is not what I expected (3 and 4 were not assigned). Even worse,
``when I did
`
>> m=zeros(3, 2, 2) ;
>> a= [ 1; 2; 3; 4] ;
>> m(3, :) = a
m =
ans(:,:,1) =
0 0
0 0
1 2
ans(:,:,2) =
0.0e+00 *
NaN NaN
NaN Inf
NaN Inf

`This gives strange values on the 2nd "page". Further more, in normal
``mode the same code gave
`
octave:8> m=zeros(3, 2, 2) ;
octave:9> a= [ 1; 2; 3; 4] ;
octave:10> m(3, :) = a
m =
ans(:,:,1) =
0 0
0 0
1 2
ans(:,:,2) =
0.0000e+00 5.1715e-319
1.1116e-321 0.0000e+00
0.0000e+00 0.0000e+00

`Is there a way to overcome this, or at least get an error/warning. I'm
``using octave-2.1.71
`
Thanks,
Amir.
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------

**newbie question: assigment to N-d arrays returns strange values**,
*Amir Seginer* **<=**