[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How do I translate Matlab's colon into Octave?
From: |
John W. Eaton |
Subject: |
How do I translate Matlab's colon into Octave? |
Date: |
Sun, 7 Sep 1997 23:48:25 -0500 |
On 5-Sep-1997, Dirk Laurie <address@hidden> wrote:
| I've got zillions of old Matlab 3.5 routines that rely on one of the
| following devices:
|
| 1. x(:) returns the contents of x as a column vector
| 2. y(:)=x assigns the contents of x to y, retaining the
| present shape of y
|
| It seems that these tricks do not work in Octave. Are there
| alternatives that do not involve massive re-coding?
Invoke Octave with --traditional:
bevo:2> octave --traditional
Octave, version 2.0.9 (alpha-dec-osf3.2).
Copyright (C) 1996, 1997 John W. Eaton.
This is free software with ABSOLUTELY NO WARRANTY.
For details, type `warranty'.
>> x = [1,2,3;4,5,6]
x =
1 2 3
4 5 6
>> x(:)
ans =
1
4
2
5
3
6
>> y = [6,5;4,3;2,1]
y =
6 5
4 3
2 1
>> y(:) = x
y =
1 5
4 3
2 6
Or, if you just want to change the indexing behavior, set the built-in
variable do_fortran_indexing to 1.
jwe