I have a matrix of 24 rows x 3 columns. How to obtain all possible combinations of 3 rows? These combinations are then solved for obtaining average value of variables.
2 次查看(过去 30 天)
显示 更早的评论
LHS is
A=[0.313976809989128 0.177956658855626 78.3488158507844;
35.5174462218438 0.203968398786232 130.746500956281;
2.01021515608203 0.206602303296522 81.6725646419809;
2.24634015155953 0.166640927463375 87.0880600273723;
13.6633712439119 0.199859900476471 94.6371224086545;
15.9528811193948 0.190429321679092 100.278409049176;
37.2448197308362 0.277981859601046 105.603760896428;
37.8682446742245 0.240480046509696 107.589144969063;
44.2889039004173 2.51076959884036 102.000035183270;
47.1249770249307 2.80167184984230 105.283913040282;
49.6287943380623 11.5567315644052 85.1349069485669;
54.8726983927937 12.7472220480560 88.7132665928202;
65.7235732009926 21.0827598977816 91.5677567497500;
62.3808138932447 19.8717817644255 92.7065438895835;
40.4367766528897 15.4158222360858 79.4796533897255;
48.9122996980167 18.3966101694915 85.5014827107762;
59.1385794772328 31.5904929035436 84.9261906960993;
68.4660446264592 36.2437215455307 87.4169710019492;
58.0081090978847 35.5973295200228 90.8130489626749;
58.1667948301691 35.0214232414543 93.8921148117136;
62.5083563651203 39.8111331639183 100.985692468451;
80.9234802795523 52.6140571604828 106.440367866101;
57.4613510889166 35.8566902483007 102.370470245526;
59.0972054988387 37.1450036236640 103.732813275735]
RHS is
C=[37;
39;
45.3;
46.1;
66;
67;
89;
90;
112.5;
115;
134.2;
135;
152.7;
153;
155.1;
156;
175.6;
176;
188.4;
189;
194.2;
194.8;
195;
196]
Considering variables as;
B=[x; y; z]
like
[A]*[B]=[C]
0 个评论
回答(2 个)
John D'Errico
2016-2-21
编辑:John D'Errico
2016-2-21
You have 24 rows in A. There are
nchoosek(24,3)
ans =
2024
sets of possible combinations of rows. You can get the indices of those rows from
C = nchoosek(1:24,3);
Each row of that result represents one desired combination. So, now
A(C(1,:),:)
will give you the first set of three rows as a 3x3 array.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!