loops - Iterate through a structure in MATLAB without 'fieldnames' -



loops - Iterate through a structure in MATLAB without 'fieldnames' -

the usual way iterate through struct info type in matlab using fieldnames() function done in:

mystruct = struct('a',3,'b',5,'c',9); fields = fieldnames(mystruct); i=1:numel(fields) mystruct.(fields{i}); end

unfortunately, generates cell info types, , utilize kind of iteration matlab function block in simulink not allow cell info types code generation reasons.

is there way iterate through construction without making utilize of cell info types @ same time?

in octave there neat way of explained in https://www.gnu.org/software/octave/doc/interpreter/looping-over-structure-elements.html

for [val, key] = mystruct # esp. 'key' end

does know similar way in matlab?

when generating code using matlab coder or simulink coder, not cell arrays disallowed, referencing fields of construction using dynamic names.

since can't utilize dynamic names, should repeat content of loop body multiple times, 1 time each field name, (since you're not using dynamic names) know in advance.

although might cumbersome programming point of view, guess it's faster anyway when generate code it, code generation process should unroll loop anyway.

matlab loops struct simulink matlab-coder

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -