Clear Filters
Clear Filters

how to loop over the structure fields and get the type of data ?!

770 views (last 30 days)
hello! I would like to loop over the fields of a structure and get the type of data for each field, so I can do further manipulation if a field is a matrix , how can I implement this into matlab ?? thank you very much !

Accepted Answer

James Tursa
James Tursa on 23 May 2017
You could loop over the fieldnames, e.g.
fn = fieldnames(mystruct);
for k=1:numel(fn)
if( isnumeric(mystruct.(fn{k})) )
% do stuff
end
end

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!