How to (nicely) copy a structure array field into another

141 views (last 30 days)
Based on several questions in this forum, the following piece of code works. But I wonder if there is a more 'elegant' or 'neat' way in Matlab ('matlabish', 'matlabonic'...?)
% S is a given structure (I definetely can't modify that)
S(1).name = [];
S(2).name = [];
% Nicely stored input data (I could parse this differently, but this is not the point)
data(1).name = 'A';
data(2).name = 'B';
% Is there a more straightforward way to achieve ' =' ?
names = {};
[] = names{:};
% Or a clean one liner that avoids using 'names' ?

Accepted Answer

Stephen23 on 1 Sep 2020
Edited: Stephen23 on 1 Sep 2020
[] = deal(
  1 Comment
Joan Vazquez
Joan Vazquez on 1 Sep 2020
Matlab's marketing department needs to popularize a proper adjective :P

Sign in to comment.

More Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by