matlab - Perform action on all fields of structure -


i wonder if it's possible perform action on all fields of structure @ once?

my scenario:

i have data eye tracker device. stored in struct data, , has following fields:

data.positionx data.positiony data.velocity data.acceleration 

each field contains vector of integers. suppose want delete sample number 10 data stream. have following:

data.positionx(10) = []; data.positiony(10) = []; data.velocity(10) = []; data.acceleration(10) = []; 

how more efficiently?

yes, use dynamic field names.

fields = fieldnames(data); i=1:length(fields)    field  = fields{i};    data.(field)(10) = []; end 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -