How to delete n element from structure
Mostrar comentarios más antiguos
How an element can be deleted from a structure. Structure is having only one field.
1 comentario
Erik S.
el 8 de Feb. de 2015
Can you give an example of your structure and its field?
Respuesta aceptada
Más respuestas (1)
Stephen23
el 8 de Feb. de 2015
The original question "How an element can be deleted from a structure" also makes sense in the context of a non-scalar struct. In MATLAB, removing any element/s of the struct can be performed in exactly the same way as removing the elemtns of any other kind of array (numeric, char, etc):
>> A = struct('dat',{1,2,3,4});
>> A(3) = [];
OR
>> A = A([1,2,4]); % <- may be faster.
2 comentarios
Image Analyst
el 8 de Feb. de 2015
That creates an array of 4 structures, with each structure in the array having one field with one scalar value assigned to that field. That was not what I thought of. I thought of one structure with one field and an array assigned to that field. Hopefully the original poster will clarify which form it is.
Stephen23
el 8 de Feb. de 2015
I have always thought of struct(1:n).(...) as being a "structure array" in and of itself, rather than being an array containing structures. Indeed this is what the documentation is subtitled " struct...Create structure array", and give syntax as " struct(field,value) creates a structure array...".
Categorías
Más información sobre Structures en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!