How to create a 3D variable with the third dimension is 1
조회 수: 15 (최근 30일)
이전 댓글 표시
I want to create a 3D variable with its third dimension is 1. However, functions such as zeros, ones and rand will ignore trailing dimensions with a size of 1.
So, if I try
A = zeros(100,100,1);
I would only have a 2D variable.
댓글 수: 1
Stephen23
2023년 6월 27일
"I want to create a 3D variable with its third dimension is 1."
A = zeros(100,100);
size(A,3)
"I would only have a 2D variable."
All arrays implicitly have infinite trailing scalar dimensions.
답변 (1개)
Nikhil Baishkiyar
2023년 6월 27일
편집: Nikhil Baishkiyar
2023년 6월 27일
This question has been asked before. This is the link
But basically Arrays in MATLAB have an implied infinitely long series of trailing singleton dimensions. You can index into them with no problem.
a = rand(100,100);
a(50,35,1)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!