MATLAB: How to count field numbers of structure structures Please let me know how to count field numbers of structure as below. Structure.A = zeros(10); Structure.B = zeros(10); Structure.C = zeros(10); there are 3 fields in structure, and I want to know number '3'. Best Answer length(fieldnames(Structure)) Related SolutionsMATLAB: Mode of table sizes within a structure With a little modification the above solution worked with acceptable speed MATLAB: How to assign the same value to every field, including nested fields of a structure A = structfun(@(s) layer2(s,x), 'Uniform', 0);together with function r = layer2(s, x) if istruct(s) fn = fieldnames(s); r = cell2struct( repmat({x}, length(fn), 1), fn, 1); else r = x; end end Related QuestionAccess data in structureFind the size of a structured arrayHow to create a structureHow to find the number of “struct” class in a structure array
Best Answer