Reid
Reid

Reputation: 39

How can I access the data returned by the function funnode?

I'm using the CompEcon package produced to solve a dynamic programming problem. I've used the builtin function funnode to produce vectors and arrays. When the function outputs vectors, I am able to access the elements of the vectors without any trouble. For example:

test2=funnode(test)

returns

test2 =
    33.4937
    250.0000
    466.5064

This is great, I can access the first element by test2(1). However, when I try to produce an array as an output, I get an object that I haven't seen before:

>> RQ_nodes = funnode(fspace)
RQ_nodes = 
    [3x1 double]    [3x1 double]
>> RQ_nodes(1)
ans = 
    [3x1 double]
>> RQ_nodes(1,1)
ans = 
    [3x1 double]

RQ_nodes looks like a 2x3 array to me. How can I access one of the elements in the first column?

Upvotes: 1

Views: 32

Answers (1)

gnovice
gnovice

Reputation: 125854

The output is a cell array, so you have to use curly braces to access the contents of a cell. For example, this will give you the first vector:

vec1 = RQ_nodes{1};

And this will give you the first element of the first vector:

elem1 = RQ_nodes{1}(1);

Upvotes: 3

Related Questions