data structure for a matrix (2 dimensional) whose elements are a vector

I'd like to encode a m-by-n matrix using matlab.
Problem is each element of the matrix should be a vector of size k.
How to encode this kind of matrix efficiently?
Thanks
Dohoon

 採用された回答

James Tursa
James Tursa 2014 年 6 月 7 日
編集済み: James Tursa 2014 年 6 月 7 日

1 投票

For memory efficiency, you can use a 3D k-by-m-by-n array A. E.g.,
A(1:k,1,1) = 1st k-vector
A(1:k,2,1) = 2nd k-vector
etc
A(1:k,m,n) = last k-vector
Then each vector's elements would be contiguous in memory and could be extracted with the syntax A(:,x,y) for the "x-y-th" vector.
If you want the syntax to be more natural but give up a little in storage efficiency you can use a cell array. E.g.,
A(1,1) = {1st k-vector}
A(2,1) = {2nd k-vector}
etc
A(m,n) = {last k-vector}
The storage requirements are a bit more than the 3D array, but each vector's elements would still be contiguous in memory and could be extracted with the syntax A{x,y} for the "x-y-th" vector.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by