[英]Three-dimensional array
在分類問題中,我有c
類數據,每個數據都有這個數據的e
例子,每個例子都由長度為f
的特征向量表示。 在Matlab中表示這種結構的最佳方法是什么?
我可以使用c-by-e
單元陣列,其中每個元素都是長度為f
1D數組。 但是,我想避免使用單元格數組。 如果我使用3D數組,我不知道如何實現它。 尺寸是多少? (c, e, f)
或(f, e, c)
?
使用3D矩陣的限制是尺寸必須具有固定長度(因此所有類必須具有相同數量的示例和特征)。
假設您需要一般性答案,並且想要避免使用單元格數組,則可以使用結構數組:
c(3).name = 'cls3'; %// name of 3rd class
c(3).example(1).name = 'c3e1'; %// name of 1st example of 3rd class
c(3).example(1).data = [1 2 3 4]; %// not sure what is your data structure here
c(3).example(1).features_ID = [101 102]; %// ID of features
c(3).example(2).name = 'c3e2';
c(3).example(2).data = [1 2 3 4 5 6];
c(3).example(2).features_ID = [101 102 103];
我只填寫了第3課,有2個例子,但你明白了。
通常,最好將最長的矢量放在一列中。 因此, (f, e, c)
應該優於(c, e, f)
,假設f
確實是最長的維度。
在列中工作時,MATLAB最有效,許多內置函數默認編碼為列式工作。
資料來源: http : //www.mathworks.com/help/images/using-columnwise-processing-to-speed-up-sliding-neighborhood-or-distinct-block-operations.html 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.