Creating a table with matrices and arrays as elements

48 ビュー (過去 30 日間)
Hi, Hope you're safe and fine.
My question is how to create a table whose elements are not necessarily of the same rows. For instance, I have attached a built-in table from "Monocular Visual Odometry" example of MATLAB. In this table, the first element is a number, the second one is a 1x3 vector of location, and the thrid one is a 3x3 matrix of rotation.
Any ideas are appreciated!

採用された回答

Stephen23
Stephen23 2021 年 3 月 6 日
編集済み: Stephen23 2021 年 3 月 6 日
Lets have a look at the data:
S = load('visualOdometryGroundTruth.mat')
S = struct with fields:
groundTruthPoses: [150×3 table]
T = S.groundTruthPoses
T = 150x3 table
ViewId Location Orientation ______ ____________ ____________ 1 {1×3 double} {3×3 double} 2 {1×3 double} {3×3 double} 3 {1×3 double} {3×3 double} 4 {1×3 double} {3×3 double} 5 {1×3 double} {3×3 double} 6 {1×3 double} {3×3 double} 7 {1×3 double} {3×3 double} 8 {1×3 double} {3×3 double} 9 {1×3 double} {3×3 double} 10 {1×3 double} {3×3 double} 11 {1×3 double} {3×3 double} 12 {1×3 double} {3×3 double} 13 {1×3 double} {3×3 double} 14 {1×3 double} {3×3 double} 15 {1×3 double} {3×3 double} 16 {1×3 double} {3×3 double}
The curly braces in the 2nd and 3rd columns tell us those numeric arrays are in a cell array. So lets do that:
VId = [2;4;8];
Loc = {[2,22,222];[4,44,444];[8,88,888]}; % cell array
Ori = { 2*rand(3); 4*rand(3); 8*rand(3)}; % cell array
out = table(VId,Loc,Ori)
out = 3x3 table
VId Loc Ori ___ ____________ ____________ 2 {1×3 double} {3×3 double} 4 {1×3 double} {3×3 double} 8 {1×3 double} {3×3 double}

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by