Azzera filtri
Azzera filtri

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

22 visualizzazioni (ultimi 30 giorni)
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 Commento
Stephen23
Stephen23 il 9 Mar 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.

Accedi per commentare.

Risposte (1)

Guillaume
Guillaume il 9 Mar 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?

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by