Iteratively concatenate 3x4 matrices held in a structure with single line arrays held in a structure
Afficher commentaires plus anciens
I have a structure, eulernew holding n 3x4 matrices (eulernew.RMn). eulernew =
RM1: [3x4 double]
RM2: [3x4 double]
RM3: [3x4 double]
RM4: [3x4 double]
RM5: [3x4 double]
RM6: [3x4 double]
Where eulernew.RM1 =
0.9994 -0.0251 0.0256 0.5053
0.0254 0.9996 -0.0082 1.4532
-0.0254 0.0088 0.9996 1.4532
I have written the following code to create a structure, IDA:
%Create origin / vector multiple array for the bottom rows of the 4 x 4
%matrices
ID = [0 0 0 1];
%Create a structure,IDA where n structure elements (IDA.I=ID)
%equate to the size, PX
IDA=struct();
for i=1:size(PX)
IDA.(['I' num2str(i)])=ID;
end
Which contains n single row arrays, I1,..,In, corresponding to the number of 3x4 arrays held in eulernew:
I1: [0 0 0 1]
I2: [0 0 0 1]
I3: [0 0 0 1]
I4: [0 0 0 1]
I5: [0 0 0 1]
I6: [0 0 0 1]
My problem is that a want to sequentially concatenate eulernew.RM1,..,RMn with IDA.I1,..,In to produce a structure containing arrays of the form:
r11 r12 r13 x
r21 r22 r23 y
r31 r32 r33 z
0 0 0 1
On the command line, I can perform this calculation on an individual basis using the command:
vertcat(eulernew.RM1,IDA.I1);
I thought about using a struct2cell function such as:
c1 = struct2cell(eulernew);
c2 = struct2cell(IDA);
Then performing the concatenation, but ended up tying myself in knots! The syntax for performing concatenation on arrays contained in two separate structures is beyond me at present (I’m very new to the programming aspect of Matlab).
Any help would be greatly appreciated.
Thomas
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!