How to write an empty matrix with 4 number of rows and 3 columns. How to write an epmty row vector.
조회 수: 22 (최근 30일)
이전 댓글 표시
Suppose I want to write a 3-by-4 empty matrix means I want to write an empty matrix with number of rows 3 and number of columns 4.
댓글 수: 1
Stephen23
2016년 3월 9일
Lets read the MATLAB documentation. isempty says: "An empty array has at least one dimension of size zero, for example, 0-by-0 or 0-by-5". The page Empty Matrices, Scalars, and Vectors says "A matrix having at least one dimension equal to zero is called an empty matrix"
You want a matrix of size 3-by-4. This is not empty.
답변 (1개)
Guillaume
2016년 3월 9일
The definition of an empty matrix is that one of the dimension has size 0. Therefore, by definition a matrix of size 3x4 is not empty. You can initialise a 3x4 for matrix so that all the elements are 0 (with zeros) or Not-A-Number (with nan) but not empty as a matrix must always contain something if it has a size.
If you really need a container of a given size with empty elements you have to use a cell array.
c = cell(3, 4); %empty cell array of size 3x4
Note that cell arrays are less efficient than matrices and a bit more awkward to use. If all you're going to put in the cell array are scalars you're better off using a matrix.
What problem are you trying to solve with empty matrices?
댓글 수: 0
참고 항목
카테고리
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!