Combining elements from two arrays
11 ビュー (過去 30 日間)
古いコメントを表示
I have two arrays to start with:
B = 0.8147 0.6324 0.9575
0.9058 0.0975 0.9649
0.1270 0.2785 0.1576
0.9134 0.5469 0.9706
and
A = 0.9572 0.1419 0.7922
0.4854 0.4218 0.9595
0.8003 0.9157 0.6557
The array i want to end with is:
C = 0.4854 0.4218
0.9572 0.1419
0.1576 0.9649
So essentially i want the 2nd, 5th, 1st and 4th element of A and the 11th and 10th element of B.
I've managed to extract the elements from A that i need using the code >> C = A([2 5 ; 1 4]) but i cannot work out how to then add the 11th and 10th element of B.
0 件のコメント
採用された回答
Torsten
2022 年 10 月 19 日
A = [0.9572 0.1419 0.7922
0.4854 0.4218 0.9595
0.8003 0.9157 0.6557];
B = [0.8147 0.6324 0.9575
0.9058 0.0975 0.9649
0.1270 0.2785 0.1576
0.9134 0.5469 0.9706];
C = [A(2,1:2);A(1,1:2);B(3,3),B(2,3)]
その他の回答 (1 件)
AH
2022 年 10 月 19 日
You may want to try this
A = [0.9572, 0.1419, 0.7922;
0.4854, 0.4218, 0.9595;
0.8003, 0.9157, 0.6557];
B = [0.8147, 0.6324, 0.9575;
0.9058, 0.0975, 0.9649;
0.1270, 0.2785, 0.1576;
0.9134, 0.5469, 0.9706];
C = [A([2 5;1 4]);B([11 10])]
参考
カテゴリ
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!