How to write an empty matrix with 4 number of rows and 3 columns. How to write an epmty row vector.
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Stephen23
el 9 de Mzo. de 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.
Respuestas (1)
Guillaume
el 9 de Mzo. de 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?
0 comentarios
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!