I'm having the following problem which I can't believe there to be a simple solution for. At any rate a google search wasn't succesful.
Suppose I make the following struct
teststruct = struct('field1',{'a','b','c'});
Now I want to add another field called 'field2' filled with 'd', 'e' and 'f'. Basically I want to achieve the result I would have achieved by directly doing.
teststruct2 = struct('field1',{'a','b','c'}, 'field2', {'d','e','f'});
I tried several solutions and the closest I got was
[teststruct(:).field2] = {'d';'e';'f'};
This however puts the entire cell on the right hand side in it's entirety in the objects 'field2' field.
Does anyone know a solution?