Filter löschen
Filter löschen

How to write an empty matrix with 4 number of rows and 3 columns. How to write an epmty row vector.

22 Ansichten (letzte 30 Tage)
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 Kommentar
Stephen23
Stephen23 am 9 Mär. 2016
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Guillaume
Guillaume am 9 Mär. 2016
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?

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by