Borrar filtros
Borrar filtros

how can I make the matrix empty when it has the values.

1 visualización (últimos 30 días)
Z D
Z D el 18 de Sept. de 2017
Respondida: Walter Roberson el 18 de Sept. de 2017
this is my code.
if j~= p(t,1)
D{j}(i,[1,2,3,4])=Cl(i,[1,2,3,4]);
else
Cl(i,[1,2,3,4])% here is my problem I want C1 to be empty but I do not know how to write?!
end

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Sept. de 2017
You can delete values, and you can overwrite an entire matrix with an empty matrix, but you cannot overwrite part of a matrix with emptiness, unless the matrix is a cell array.
Cl(i,:) = [];
would delete all of row #i from C1.
c1(i,1) = [];
would delete just the element in column 1 of row #i. But as a side effect, because holes are not allowed in numeric arrays, the entire array would become a single column vector, the same as if you had done:
t = c1(:); %make it a column vector
t( sub2ind(size(c1), i, 1) ) = []; %delete the one element of the column vector
c1 = t; %that is the new c1
After that, there would be no c1(i,2) because it would be down to a single column.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by