Access to a vector in cell in Matlab

后端 未结 1 960
梦如初夏
梦如初夏 2020-12-06 21:57

C is a cell consisting of some vectors:

C = {[1, 2], [2, 3]};

I want to read the first entry of the first vector in C

相关标签:
1条回答
  • 2020-12-06 22:46

    You can access individual elements of matrices in cell array like this:

    C{n,m}(ii,jj);
    

    This will give you element (ii,jj) of the matrix at index (n,m) of the cell array.

    Hence, for your particular example,

    val = C{1,1}(1,1) (or val = C{1}(1))

    will assign the value of the first element of the first vector in the cell array to the variable val.

    0 讨论(0)
提交回复
热议问题