Tae-Sung Shin
Tae-Sung Shin

Reputation: 20610

Accessing value from a strange object in matlab

When I type in the object in Matlab like this

>> a

I got following.

ans = 

    [6x1004 uint16]

How can I access a cell of the object a, for example cell of (2,4)?

I tried a(2,4) or a[2,4] in vain.

I understand this is a noob question but have no idea where I can start.

Upvotes: 2

Views: 79

Answers (3)

Lucas
Lucas

Reputation: 14129

To find out the class of an object you can use the class function.

>> a{1} = uint16(zeros(6,1004));
>> a

a = 

    [6x1004 uint16]

>> class(a)

ans =

cell

Upvotes: 2

Sevenless
Sevenless

Reputation: 2835

This should help:

>> a = cell(1);
>> a{1} = rand(6,1004);
>> a

a = 

    [6x1004 double]

>> a{1}(1)

ans =

    0.8147

When referencing a cell () returns the cell, {} returns the contents of the cell.

Upvotes: 3

Azim J
Azim J

Reputation: 8290

It looks like a is a cell variable of size 1x1. So, did you try indexing with {}, eg

a{1}(2,4)

Upvotes: 5

Related Questions