フィルターのクリア

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
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
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?

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by