Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- B(3) = A;
- %defines input stract
- a.f1 = 2; a.f2 = 3; a.f3 = 'str';
- temp.f2=5; temp.f3 = 7; temp.f4 =1;
- b(1) = temp; b(2) = temp; b(3) = temp;
- %iterates over the fields of a and assigns their values into b
- fields = fieldnames(a);
- for ii = 1:numel(fields)
- b(3).(fields{ii}) = a.(fields{ii});
- end
- a =
- f1: 2
- f2: 3
- f3: 'str'
- b(3) =
- f2: 5
- f3: 7
- f4: 1
- b(3)=
- f2: 3
- f3: 'str'
- f4: 1
- f1: 2
Add Comment
Please, Sign In to add comment