[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[foo{:}] - feature or bug ? (octave-3.4.2)
From: |
Sergei Steshenko |
Subject: |
[foo{:}] - feature or bug ? (octave-3.4.2) |
Date: |
Sat, 6 Aug 2011 05:14:42 -0700 (PDT) |
Hello,
I've decided to read yet another time
http://www.gnu.org/software/octave/doc/interpreter/Comma-Separated-Lists-Generated-from-Cell-Arrays.html#Comma-Separated-Lists-Generated-from-Cell-Arrays
:
"
...elements of a cell array can be extracted into a comma separated list with
the { and } operators. By surrounding this list with [ and ], it can be
concatenated into an array.
"
and to try something simple WRT "concatenated into an array" above. So
here is the screen session:
"
octave:1> foo{1} = "a"
foo =
{
[1,1] = a
}
octave:2> foo{2} = "ab"
foo =
{
[1,1] = a
[1,2] = ab
}
octave:3> foo{3} = "abc"
foo =
{
[1,1] = a
[1,2] = ab
[1,3] = abc
}
octave:4> foo{4} = [1 2 3 4]
foo =
{
[1,1] = a
[1,2] = ab
[1,3] = abc
[1,4] =
1 2 3 4
}
octave:5> numel(foo)
ans = 4
octave:6> numel(foo{:})
ans = 24
octave:7> [foo{:}]
ans = aababc
octave:8> numel([foo{:}])
ans = 10
octave:9> [foo{:}](1)
ans = a
octave:10> [foo{:}](2)
ans = a
octave:11> [foo{:}](3)
ans = b
octave:12> [foo{:}](4)
ans = a
octave:13> [foo{:}](5)
ans = b
octave:14> [foo{:}](6)
ans = c
octave:15> [foo{:}](7)
ans =
octave:16> [foo{:}](8)
ans =
octave:17> [foo{:}](9)
ans =
octave:18> [foo{:}](10)
ans =
octave:19>
".
Questions:
1) why in
"
octave:7> [foo{:}]
ans = aababc
"
I do _not_ see any trace of "[1 2 3 4]" vector ?
2) why [foo{:}](7) .. [foo{:}](10) show emptiness ?
.
Or, in general terms: where/how the "[1 2 3 4]" vector was concatenated ?
...
And, of course, a 2-d session:
"
octave:1> bar{1,1} = "a"
bar =
{
[1,1] = a
}
octave:2> bar{1,2} = "b"
bar =
{
[1,1] = a
[1,2] = b
}
octave:3> bar{2, 1} = [1 2 3 4]
bar =
{
[1,1] = a
[2,1] =
1 2 3 4
[1,2] = b
[2,2] = [](0x0)
}
octave:4> numel(bar)
ans = 4
octave:5> numel(bar{:})
ans = 0
octave:6> [bar{:}]
ans = ab
octave:7> numel([bar{:}])
ans = 6
octave:8> [bar{:}](1)
ans = a
octave:9> [bar{:}](2)
ans =
octave:10> [bar{:}](3)
ans =
octave:11> [bar{:}](4)
ans =
octave:12> [bar{:}](5)
ans =
octave:13> [bar{:}](6)
ans = b
octave:14>
"
- the same questions apply.
...
Back to 1-d:
"
octave:1> doo{1} = "a"
doo =
{
[1,1] = a
}
octave:2> doo{2} = "b"
doo =
{
[1,1] = a
[1,2] = b
}
octave:3> doo{3} = inf
doo =
{
[1,1] = a
[1,2] = b
[1,3] = Inf
}
octave:4> doo{4} = [1 2 3 4]
doo =
{
[1,1] = a
[1,2] = b
[1,3] = Inf
[1,4] =
1 2 3 4
}
octave:5> numel(doo)
ans = 4
octave:6> numel(doo{:})
ans = 4
octave:7> [doo{:}]
ans = ab
octave:8> numel([doo{:}])
ans = 7
octave:9> [doo{:}](1)
ans = a
octave:10> [doo{:}](2)
ans = b
octave:11> [doo{:}](3)
ans =
octave:12> [doo{:}](4)
ans =
octave:13> [doo{:}](5)
ans =
octave:14> [doo{:}](6)
ans =
octave:15> [doo{:}](7)
ans =
octave:16>
"
- in addition to already asked questions: where is "inf" in
"
octave:7> [doo{:}]
ans = ab
"
?
Thanks,
Sergei.
- [foo{:}] - feature or bug ? (octave-3.4.2),
Sergei Steshenko <=