modify and repalce structure fields
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a structure ALL with 42 misc fields. One of these fields is a structure E with 4 fields (A,B,C,D), each of size N. I need to modify these fields and replace structure E with a new structure E that will have approximately N/4 elements.I am having difficult indexing the ABCD fields so I can manipualte them. I can do this for instance to extract the ALL.E.C field and print it to the comand window, but nothing I try will allow me to extrract it and put it into a double array so I can manipulate it.
ALL.E(1:end).C ----> prints to command window
I tried this
struct2cell(ALL.E(1:end).C) ---> error
but it said it would not work with arguments of 'double' Can someone please suggest a way I can achieve my goal?
-Jeff
0 comentarios
Respuestas (1)
Sriram Tadavarty
el 22 de Mzo. de 2020
Hi Jeff,
You can try indexing as such
>> ALL.E.A % ALL is a structure with field E and field E has another field A
% To replace A field with 1/4 elements
>> ALL.E.A = rand(1,N/4); % Replace with the respective elements as you need
% Peform this for other fields B,C, and D
% TO replace the complete structure
>> ALL.E = F; % F is another structure
Hope this helps.
Regards,
Sriram
0 comentarios
Ver también
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!