Borrar filtros
Borrar filtros

How to remove an element from a structure array using matfile handler

1 visualización (últimos 30 días)
Abdurrehman
Abdurrehman el 27 de Jul. de 2018
Editada: Walter Roberson el 28 de Jul. de 2018
Hi,
I am using following piece of code to remove an element from a structure array, but its not working please help
MatfileHandler.StructureArray(index,:)=[];
since the above wasn't working thus I used following statements.
AllElements = MatfileHandler.StructureArray; %loaded all elements in AllElements
AllElements(index,:)=[]; %Removed the required element
MatfileHandler.StructureArray = AllElements; %Resaving the AllElements to Actual Matfile
the above code works fine but it takes too much time especially when the size of structure is big. Please help me how to reduce time or remove element by using matfile handler, thanks.
  3 comentarios
Abdurrehman
Abdurrehman el 27 de Jul. de 2018
MatfileHandler = matfile('filename.mat','Writable',true);
My Structure is 36x1 array with 12 fields consisting of cell and double data types
Abdurrehman
Abdurrehman el 28 de Jul. de 2018
Precisely speaking I had to say matfile object

Iniciar sesión para comentar.

Respuestas (1)

Guillaume
Guillaume el 27 de Jul. de 2018
As documented in the limitations of matfile, it does not let you index into the fields of a structure. Therefore the only way is to do what you have done: load the whole structure, edit the structure and write it back.

Categorías

Más información sobre Structures 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!

Translated by