Borrar filtros
Borrar filtros

clearing an instance of a structure variable

7 visualizaciones (últimos 30 días)
PN
PN el 24 de En. de 2011
hello!
I was wondering whether it is possible to clear an instance on a structure variable, as in the following example.
a = struct('name',0,'age'',0)
a(1) = struct('name','jack','age',20);
a(2) = struct('name','fred','age',28);
So my question would be: is there a way to clear either a(1), for instance, such that the final length of 'a' becomes 1, instead of 2?

Respuesta aceptada

Kenneth Eaton
Kenneth Eaton el 24 de En. de 2011
You can remove an element from a structure array the same way you can remove an element from any other type of array:
a(1) = []; % Set the first element to empty
Or:
a = a(2); % Index the second element and reassign it to a

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 24 de En. de 2011

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by