________________________________
From: Joanna Rutkowska <address@hidden>
To: address@hidden
Sent: Thursday, October 25, 2012 9:46 PM
Subject: Lists of objects?
[snip]
obj1 = xxx ()
list = {list, obj1}
obj2 = xxx ()
list = {list, obj2}
The code above unfortunately doesn't work well, because it creates nested cell
arrays.
?
[snip]
Thanks,
joanna.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave
According to Jordi, I am well known for misunderstanding of cell arrays,
structs, etc., but somehow I manage them to do what I need.
How about the following:
"octave:1> list_of_objects = {}
list_of_objects = {}(0x0)
octave:2> foo = 1
foo = 1
octave:3> list_of_objects{end + 1} = foo
list_of_objects =
{
[1,1] = 1
}
octave:4> bar = [1 2 3]
bar =
1 2 3
octave:5> list_of_objects{end + 1} = bar
list_of_objects =
{
[1,1] = 1
[1,2] =
1 2 3
}
octave:6> doo = [4 5 6; 7 8 9]
doo =
4 5 6
7 8 9
octave:7> list_of_objects{end + 1} = doo
list_of_objects =
{
[1,1] = 1
[1,2] =
1 2 3
[1,3] =
4 5 6
7 8 9
}
octave:8> boo = "Hello"
boo = Hello
octave:9> list_of_objects{end + 1} = boo
list_of_objects =
{
[1,1] = 1
[1,2] =
1 2 3
[1,3] =
4 5 6
7 8 9
[1,4] = Hello
}
octave:10> list_of_objects
list_of_objects =
{
[1,1] = 1
[1,2] =
1 2 3
[1,3] =
4 5 6
7 8 9
[1,4] = Hello
}
octave:11> list_of_objects{3}
ans =
4 5 6
7 8 9
octave:12>
"
?