matrices specific value selection

2 ビュー (過去 30 日間)
Ihaveaquest
Ihaveaquest 2022 年 8 月 29 日
コメント済み: Voss 2022 年 8 月 30 日
disp(B.values(2:1:end));
im trying to use this format but it gives me all of the numbers i need the first number and last of multiple sections
B.values =
val(:,:,1) =
92 99 1 8 15 67 74 51 58 40
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
86 93 25 2 9 61 68 75 52 34
17 24 76 83 90 42 49 26 33 65
23 5 82 89 91 48 30 32 39 66
79 6 13 95 97 29 31 38 45 72
10 12 94 96 78 35 37 44 46 53
11 18 100 77 84 36 43 50 27 59
val(:,:,2) =
88 99 1 8 15 67 74 51 58 69
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
86 93 25 2 9 61 68 75 52 34
17 24 76 83 90 42 49 26 33 65
23 5 82 89 91 48 30 32 39 66
79 6 13 95 97 29 31 38 45 72
10 12 94 96 78 35 37 44 46 53
11 18 100 77 84 36 43 50 27 59
val(:,:,3) =
4 99 1 8 15 67 74 51 58 68
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
86 93 25 2 9 61 68 75 52 34
17 24 76 83 90 42 49 26 33 65
23 5 82 89 91 48 30 32 39 66
79 6 13 95 97 29 31 38 45 72
10 12 94 96 78 35 37 44 46 53
11 18 100 77 84 36 43 50 27 59

採用された回答

Voss
Voss 2022 年 8 月 29 日
Like this?
% constructing your B.values
B.values = cat(3,[ ...
92 99 1 8 15 67 74 51 58 40
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
86 93 25 2 9 61 68 75 52 34
17 24 76 83 90 42 49 26 33 65
23 5 82 89 91 48 30 32 39 66
79 6 13 95 97 29 31 38 45 72
10 12 94 96 78 35 37 44 46 53
11 18 100 77 84 36 43 50 27 59],[ ...
88 99 1 8 15 67 74 51 58 69
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
86 93 25 2 9 61 68 75 52 34
17 24 76 83 90 42 49 26 33 65
23 5 82 89 91 48 30 32 39 66
79 6 13 95 97 29 31 38 45 72
10 12 94 96 78 35 37 44 46 53
11 18 100 77 84 36 43 50 27 59],[ ...
4 99 1 8 15 67 74 51 58 68
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
86 93 25 2 9 61 68 75 52 34
17 24 76 83 90 42 49 26 33 65
23 5 82 89 91 48 30 32 39 66
79 6 13 95 97 29 31 38 45 72
10 12 94 96 78 35 37 44 46 53
11 18 100 77 84 36 43 50 27 59])
B = struct with fields:
values: [10×10×3 double]
% first value of each page
B.values(1,1,:)
ans =
ans(:,:,1) = 92 ans(:,:,2) = 88 ans(:,:,3) = 4
% last value of each page
B.values(end,end,:)
ans =
ans(:,:,1) = 59 ans(:,:,2) = 59 ans(:,:,3) = 59
  2 件のコメント
Ihaveaquest
Ihaveaquest 2022 年 8 月 30 日
Thank you works like magic! I tried everything but the option (x,x,:) great help
I wish there was a list with these options listed, heres the ones i have used for anyone looking
variables
disp(A);
disp(B);
disp(A(1,:)); %reads first complete row --->>>
disp(B(2:2:end)); %reads Second row and and first column every two location
disp(A(:,1)); %reads all of first column
disp(B(:,2:end)); %reads second column until end
disp(B(2,:,2:end));
disp(B(2:1:end));
disp(B(2,1,:));
Voss
Voss 2022 年 8 月 30 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by