Matrix1= randn(3,4,5); Matrix1(2,​:,:)是一个1行、​4列、5层的三维矩阵​; Matrix1(:,​2,:)是一个3行、​1列、5层的三维矩阵​; Matrix1(:,​:,2)却是一个3行​、4列的二维矩阵。为​什么?

8 ビュー (過去 30 日間)
艺铭
艺铭 2024 年 10 月 9 日
回答済み: DGM 2024 年 10 月 9 日
Matrix1= randn(3,4,5);
Matrix1(2,:,:)是一个1行、4列、5层的三维矩阵; Matrix1(:,2,:)是一个3行、1列、5层的三维矩阵; Matrix1(:,:,2)却是一个3行、4列的二维矩阵。为什么?

採用された回答

DGM
DGM 2024 年 10 月 9 日
This array has 3 rows, 4 columns, and 5 pages.
M = randn(3,4,5);
Try to visualize it in three dimensions:
The colon, : operator in this context by itself selects all of a specified dimension.
Then M(2,:,:) selects row 2, all columns, all pages:
M(:,2,:) selects column 2, all rows, all pages:
M(:,:,2) selects page 2, all rows, all columns:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!